本文整理汇总了C++中Printf函数的典型用法代码示例。如果您正苦于以下问题:C++ Printf函数的具体用法?C++ Printf怎么用?C++ Printf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Printf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Printf
void DataFlowTrace::Init(const std::string &DirPath,
const std::string &FocusFunction) {
if (DirPath.empty()) return;
const char *kFunctionsTxt = "functions.txt";
Printf("INFO: DataFlowTrace: reading from '%s'\n", DirPath.c_str());
Vector<SizedFile> Files;
GetSizedFilesFromDir(DirPath, &Files);
std::string L;
// Read functions.txt
std::ifstream IF(DirPlusFile(DirPath, kFunctionsTxt));
size_t FocusFuncIdx = SIZE_MAX;
size_t NumFunctions = 0;
while (std::getline(IF, L, '\n')) {
NumFunctions++;
if (FocusFunction == L)
FocusFuncIdx = NumFunctions - 1;
}
if (!NumFunctions || FocusFuncIdx == SIZE_MAX || Files.size() <= 1)
return;
// Read traces.
size_t NumTraceFiles = 0;
size_t NumTracesWithFocusFunction = 0;
for (auto &SF : Files) {
auto Name = Basename(SF.File);
if (Name == kFunctionsTxt) continue;
auto ParseError = [&](const char *Err) {
Printf("DataFlowTrace: parse error: %s\n File: %s\n Line: %s\n", Err,
Name.c_str(), L.c_str());
};
NumTraceFiles++;
// Printf("=== %s\n", Name.c_str());
std::ifstream IF(SF.File);
while (std::getline(IF, L, '\n')) {
size_t SpacePos = L.find(' ');
if (SpacePos == std::string::npos)
return ParseError("no space in the trace line");
if (L.empty() || L[0] != 'F')
return ParseError("the trace line doesn't start with 'F'");
size_t N = std::atol(L.c_str() + 1);
if (N >= NumFunctions)
return ParseError("N is greater than the number of functions");
if (N == FocusFuncIdx) {
NumTracesWithFocusFunction++;
const char *Beg = L.c_str() + SpacePos + 1;
const char *End = L.c_str() + L.size();
assert(Beg < End);
size_t Len = End - Beg;
Vector<uint8_t> V(Len);
for (size_t I = 0; I < Len; I++) {
if (Beg[I] != '0' && Beg[I] != '1')
ParseError("the trace should contain only 0 or 1");
V[I] = Beg[I] == '1';
}
Traces[Name] = V;
// Print just a few small traces.
if (NumTracesWithFocusFunction <= 3 && Len <= 16)
Printf("%s => |%s|\n", Name.c_str(), L.c_str() + SpacePos + 1);
break; // No need to parse the following lines.
}
}
}
assert(NumTraceFiles == Files.size() - 1);
Printf("INFO: DataFlowTrace: %zd trace files, %zd functions, "
"%zd traces with focus function\n",
NumTraceFiles, NumFunctions, NumTracesWithFocusFunction);
}
示例2: G_ChangeLevel
void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill)
{
level_info_t *nextinfo = NULL;
if (unloading)
{
Printf (TEXTCOLOR_RED "Unloading scripts cannot exit the level again.\n");
return;
}
if (gameaction == ga_completed && !(i_compatflags2 & COMPATF2_MULTIEXIT)) // do not exit multiple times.
{
return;
}
if (levelname == NULL || *levelname == 0)
{
// end the game
levelname = NULL;
if (!level.NextMap.Compare("enDSeQ",6))
{
nextlevel = level.NextMap; // If there is already an end sequence please leave it alone!
}
else
{
nextlevel.Format("enDSeQ%04x", int(gameinfo.DefaultEndSequence));
}
}
else if (strncmp(levelname, "enDSeQ", 6) != 0)
{
FString reallevelname = levelname;
CheckWarpTransMap(reallevelname, true);
nextinfo = FindLevelInfo (reallevelname, false);
if (nextinfo != NULL)
{
level_info_t *nextredir = nextinfo->CheckLevelRedirect();
if (nextredir != NULL)
{
nextinfo = nextredir;
}
nextlevel = nextinfo->MapName;
}
else
{
nextlevel = levelname;
}
}
else
{
nextlevel = levelname;
}
if (nextSkill != -1)
NextSkill = nextSkill;
if (flags & CHANGELEVEL_NOINTERMISSION)
{
level.flags |= LEVEL_NOINTERMISSION;
}
cluster_info_t *thiscluster = FindClusterInfo (level.cluster);
cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL;
startpos = position;
gameaction = ga_completed;
if (nextinfo != NULL)
{
if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB)))
{
if (nextinfo->flags2 & LEVEL2_RESETINVENTORY)
{
flags |= CHANGELEVEL_RESETINVENTORY;
}
if (nextinfo->flags2 & LEVEL2_RESETHEALTH)
{
flags |= CHANGELEVEL_RESETHEALTH;
}
}
}
changeflags = flags;
bglobal.End(); //Added by MC:
// [RH] Give scripts a chance to do something
unloading = true;
FBehavior::StaticStartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true);
unloading = false;
STAT_ChangeLevel(nextlevel);
if (thiscluster && (thiscluster->flags & CLUSTER_HUB))
{
if ((level.flags & LEVEL_NOINTERMISSION) || (nextcluster == thiscluster))
NoWipe = 35;
D_DrawIcon = "TELEICON";
}
for(int i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
//.........这里部分代码省略.........
示例3: Uprintf
void Uprintf(char *string, int length, int num_1, int num_2, int num_3, int num_4) {
Printf(string, length, (num_1 * 100000) + num_2, (num_3 * 100000) + num_4);
}
示例4: main_makeOCDB
void main_makeOCDB(Int_t runNumber, TString targetOCDBstorage="", TString sourceOCDBstorage="raw://", Int_t detectorBitsQualityFlag = -1)
{
//
// extract OCDB entries for detectors participating in the calibration for the current run
//
// switch off log info
AliLog::SetClassDebugLevel("AliESDEvent",0);
// config GRP
printf("runNumber from runCalibTrain = %d\n",runNumber);
ConfigCalibTrain(runNumber, sourceOCDBstorage.Data());
// check the presence of the detectors
AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
if (!grpData) {printf("Failed to get GRP data for run %d",runNumber); return;}
Int_t activeDetectors = grpData->GetDetectorMask();
TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors);
printf("Detectors in the data:\n%s\n",detStr.Data());
TString LHCperiod = grpData->GetLHCPeriod();
Bool_t isLHC10 = LHCperiod.Contains("LHC10");
Bool_t isLHC11 = LHCperiod.Contains("LHC11");
Bool_t isLHC12 = LHCperiod.Contains("LHC12");
Bool_t isLHC13 = LHCperiod.Contains("LHC13");
Bool_t isLHC13b = LHCperiod.Contains("LHC13b");
Bool_t isLHC13c = LHCperiod.Contains("LHC13c");
printf("LHCperiod:%s\n isLHC10:%d isLHC11:%d isLHC12:%d isLHC13:%d isLHC13b:%d isLHC13c:%d\n",LHCperiod.Data(),(Int_t)isLHC10,(Int_t)isLHC11,(Int_t)isLHC12,(Int_t)isLHC13,(Int_t)isLHC13b,(Int_t)isLHC13c);
TString beamtype=grpData->GetBeamType();
// Steering Tasks - set output storage
// DefaultStorage set already before - in ConfigCalibTrain.C
// Setting the mirror SEs for the default storage
TString mirrorsStr(gSystem->Getenv("MIRRORSE") ? gSystem->Getenv("MIRRORSE") : "ALICE::CERN::OCDB,ALICE::FZK::SE,ALICE::CNAF::SE");
AliCDBManager::Instance()->SetMirrorSEs(mirrorsStr.Data());
printf("List of mirror SEs set to: \"%s\"\n",mirrorsStr.Data());
// activate target OCDB storage
AliCDBStorage* targetStorage = 0x0;
if (targetOCDBstorage.Length()==0) {
targetOCDBstorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data());
}
else if (targetOCDBstorage.CompareTo("same",TString::kIgnoreCase) == 0 ){
targetStorage = AliCDBManager::Instance()->GetDefaultStorage();
}
else {
targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data());
}
printf("** targetOCDBstorage: \"%s\"\n",targetOCDBstorage.Data());
// specific storage for TPC/Calib/Correction entry
if (gSystem->AccessPathName("TPC", kFileExists)==0) {
AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Correction","local://");
}
// Magnetic field
AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
Double_t bz = fld->SolenoidField();
Bool_t isMagFieldON = kTRUE;
if (TMath::Abs(bz)>0) {
printf("Mag field is %f --> ON\n", bz);
}
else {
isMagFieldON = kFALSE;
printf("Mag field is %f --> OFF\n", bz);
}
// Quality flags
Bool_t TPC_qf = kTRUE;
Bool_t TOF_qf = kTRUE;
Bool_t TRD_qf = kTRUE;
Bool_t T0_qf = kTRUE;
Bool_t SDD_qf = kTRUE;
Bool_t SPD_qf = kTRUE;
Bool_t AD_qf = kTRUE;
/*
// RS: commenting to sync with working version from alidaq
if (detectorBitsQualityFlag != -1){
TPC_qf = ((detectorBitsQualityFlag & AliDAQ::kTPC_QF) == AliDAQ::kTPC_QF)? kTRUE : kFALSE;
TOF_qf = ((detectorBitsQualityFlag & AliDAQ::kTOF_QF) == AliDAQ::kTOF_QF)? kTRUE : kFALSE;
TRD_qf = ((detectorBitsQualityFlag & AliDAQ::kTRD_QF) == AliDAQ::kTRD_QF)? kTRUE : kFALSE;
T0_qf = ((detectorBitsQualityFlag & AliDAQ::kT0_QF) == AliDAQ::kT0_QF)? kTRUE : kFALSE;
SDD_qf = ((detectorBitsQualityFlag & AliDAQ::kSDD_QF) == AliDAQ::kSDD_QF)? kTRUE : kFALSE;
SPD_qf = ((detectorBitsQualityFlag & AliDAQ::kSPD_QF) == AliDAQ::kSPD_QF)? kTRUE : kFALSE;
AD_qf = ((detectorBitsQualityFlag & AliDAQ::kAD_QF) == AliDAQ::kAD_QF)? kTRUE : kFALSE;
}
*/
Printf("Quality flags: detectorBitsQualityFlag = %d, TPC = %d, TOF = %d, TRD = %d, T0 = %d, SDD = %d, SPD = %d, AD = %d", detectorBitsQualityFlag, (Int_t)TPC_qf, (Int_t)TOF_qf, (Int_t)TRD_qf, (Int_t)T0_qf, (Int_t)SDD_qf, (Int_t)SPD_qf, (Int_t)AD_qf);
// ===========================================================================
// ===| TPC part |============================================================
//
AliTPCPreprocessorOffline *procesTPC = 0;
if (detStr.Contains("TPC") && TPC_qf){
Printf("\n******* Calibrating TPC *******");
//.........这里部分代码省略.........
示例5: main
void main (int argc, char *argv[])
{
int numprocs = 0; // Used to store number of processes to create
int i; // Loop index variable
missile_code *mc; // Used to get address of shared memory page
uint32 h_mem; // Used to hold handle to shared memory page
sem_t s_procs_completed; // Semaphore used to wait until all spawned processes have completed
char h_mem_str[10]; // Used as command-line argument to pass mem_handle to new processes
char s_procs_completed_str[10]; // Used as command-line argument to pass page_mapped handle to new processes
if (argc != 2) {
Printf("Usage: "); Printf(argv[0]); Printf(" <number of processes to create>\n");
Exit();
}
// Convert string from ascii command line argument to integer number
numprocs = dstrtol(argv[1], NULL, 10); // the "10" means base 10
Printf("Creating %d processes\n", numprocs);
// Allocate space for a shared memory page, which is exactly 64KB
// Note that it doesn't matter how much memory we actually need: we
// always get 64KB
if ((h_mem = shmget()) == 0) {
Printf("ERROR: could not allocate shared memory page in "); Printf(argv[0]); Printf(", exiting...\n");
Exit();
}
// Map shared memory page into this process's memory space
if ((mc = (missile_code *)shmat(h_mem)) == NULL) {
Printf("Could not map the shared page to virtual address in "); Printf(argv[0]); Printf(", exiting..\n");
Exit();
}
// Put some values in the shared memory, to be read by other processes
mc->numprocs = numprocs;
mc->really_important_char = 'A';
// Create semaphore to not exit this process until all other processes
// have signalled that they are complete. To do this, we will initialize
// the semaphore to (-1) * (number of signals), where "number of signals"
// should be equal to the number of processes we're spawning - 1. Once
// each of the processes has signaled, the semaphore should be back to
// zero and the final sem_wait below will return.
if ((s_procs_completed = sem_create(-(numprocs-1))) == SYNC_FAIL) {
Printf("Bad sem_create in "); Printf(argv[0]); Printf("\n");
Exit();
}
// Setup the command-line arguments for the new process. We're going to
// pass the handles to the shared memory page and the semaphore as strings
// on the command line, so we must first convert them from ints to strings.
ditoa(h_mem, h_mem_str);
ditoa(s_procs_completed, s_procs_completed_str);
// Now we can create the processes. Note that you MUST end your call to
// process_create with a NULL argument so that the operating system
// knows how many arguments you are sending.
for(i=0; i<numprocs; i++) {
Printf("h_mem_str : %s semaphore_str : %s", h_mem_str, s_procs_completed_str);
process_create(FILENAME_TO_RUN, h_mem_str, s_procs_completed_str, NULL);
Printf("Process %d created\n", i);
}
// And finally, wait until all spawned processes have finished.
if (sem_wait(s_procs_completed) != SYNC_SUCCESS) {
Printf("Bad semaphore s_procs_completed (%d) in ", s_procs_completed); Printf(argv[0]); Printf("\n");
Exit();
}
Printf("All other processes completed, exiting main process.\n");
}
示例6: PrintLastError
static void PrintLastError ()
{
Printf (TEXTCOLOR_RED " %s\n", strerror(errno));
}
示例7: M_GetCajunPath
bool FCajunMaster::LoadBots ()
{
FScanner sc;
FString tmp;
bool gotteam = false;
int loaded_bots = 0;
bglobal.ForgetBots ();
tmp = M_GetCajunPath(BOTFILENAME);
if (tmp.IsEmpty())
{
DPrintf ("No " BOTFILENAME ", so no bots\n");
return false;
}
sc.OpenFile(tmp);
while (sc.GetString ())
{
if (!sc.Compare ("{"))
{
sc.ScriptError ("Unexpected token '%s'\n", sc.String);
}
botinfo_t *newinfo = new botinfo_t;
bool gotclass = false;
memset (newinfo, 0, sizeof(*newinfo));
newinfo->info = copystring ("\\autoaim\\0\\movebob\\.25");
for (;;)
{
sc.MustGetString ();
if (sc.Compare ("}"))
break;
switch (sc.MatchString (BotConfigStrings))
{
case BOTCFG_NAME:
sc.MustGetString ();
appendinfo (newinfo->info, "name");
appendinfo (newinfo->info, sc.String);
newinfo->name = copystring (sc.String);
break;
case BOTCFG_AIMING:
sc.MustGetNumber ();
newinfo->skill.aiming = sc.Number;
break;
case BOTCFG_PERFECTION:
sc.MustGetNumber ();
newinfo->skill.perfection = sc.Number;
break;
case BOTCFG_REACTION:
sc.MustGetNumber ();
newinfo->skill.reaction = sc.Number;
break;
case BOTCFG_ISP:
sc.MustGetNumber ();
newinfo->skill.isp = sc.Number;
break;
case BOTCFG_TEAM:
{
char teamstr[16];
BYTE teamnum;
sc.MustGetString ();
if (IsNum (sc.String))
{
teamnum = atoi (sc.String);
if (!TeamLibrary.IsValidTeam (teamnum))
{
teamnum = TEAM_NONE;
}
}
else
{
teamnum = TEAM_NONE;
for (unsigned int i = 0; i < Teams.Size(); ++i)
{
if (stricmp (Teams[i].GetName (), sc.String) == 0)
{
teamnum = i;
break;
}
}
}
appendinfo (newinfo->info, "team");
mysnprintf (teamstr, countof(teamstr), "%d", teamnum);
appendinfo (newinfo->info, teamstr);
gotteam = true;
break;
}
default:
if (stricmp (sc.String, "playerclass") == 0)
//.........这里部分代码省略.........
示例8: Printf
void TextWindow::ShowListOfStyles(void) {
Printf(true, "%Ft color style-name");
bool darkbg = false;
Style *s;
for(s = SK.style.First(); s; s = SK.style.NextAfter(s)) {
Printf(false, "%Bp %Bz %Bp %Fl%Ll%f%D%s%E",
darkbg ? 'd' : 'a',
&s->color,
darkbg ? 'd' : 'a',
ScreenShowStyleInfo, s->h.v,
s->DescriptionString());
darkbg = !darkbg;
}
Printf(true, " %Fl%Ll%fcreate a new custom style%E",
&ScreenCreateCustomStyle);
Printf(false, "");
RgbColor rgb = SS.backgroundColor;
Printf(false, "%Ft background color (r, g, b)%E");
Printf(false, "%Ba %@, %@, %@ %Fl%D%f%Ll[change]%E",
rgb.redF(), rgb.greenF(), rgb.blueF(),
top[rows-1] + 2, &ScreenChangeBackgroundColor);
Printf(false, "");
Printf(false, "%Ft background bitmap image%E");
if(SS.bgImage.fromFile) {
Printf(false, "%Ba %Ftwidth:%E %dpx %Ftheight:%E %dpx",
SS.bgImage.w, SS.bgImage.h);
Printf(false, " %Ftscale:%E %# px/%s %Fl%Ll%f%D[change]%E",
SS.bgImage.scale*SS.MmPerUnit(),
SS.UnitName(),
&ScreenChangeBackgroundImageScale, top[rows-1] + 2);
Printf(false, "%Ba %Fl%Lc%fclear background image%E",
&ScreenBackgroundImage);
} else {
Printf(false, "%Ba none - %Fl%Ll%fload background image%E",
&ScreenBackgroundImage);
Printf(false, " (bottom left will be center of view)");
}
Printf(false, "");
Printf(false, " %Fl%Ll%fload factory defaults%E",
&ScreenLoadFactoryDefaultStyles);
}
示例9: GuardNotDead
void GuardNotDead()
{
Printf(Exception,"CCore::Video::GuardNotDead() : frame window is alive");
}
示例10: while
bool FCajunMaster::SpawnBot (const char *name, int color)
{
//COLORS
static const char colors[11][17] =
{
"\\color\\40 cf 00", //0 = Green
"\\color\\b0 b0 b0", //1 = Gray
"\\color\\50 50 60", //2 = Indigo
"\\color\\8f 00 00", //3 = Deep Red
"\\color\\ff ff ff", //4 = White
"\\color\\ff af 3f", //5 = Bright Brown
"\\color\\bf 00 00", //6 = Red
"\\color\\00 00 ff", //7 = Blue
"\\color\\00 00 7f", //8 = Dark Blue
"\\color\\ff ff 00", //9 = Yellow
"\\color\\cf df 90" //10 = Bleached Bone
};
botinfo_t *thebot = botinfo;
int botshift = 0;
if (name)
{
// Check if exist or already in the game.
while (thebot && stricmp (name, thebot->name))
{
botshift++;
thebot = thebot->next;
}
if (thebot == NULL)
{
Printf ("couldn't find %s in %s\n", name, BOTFILENAME);
return false;
}
else if (thebot->inuse == BOTINUSE_Waiting)
{
return false;
}
else if (thebot->inuse == BOTINUSE_Yes)
{
Printf ("%s is already in the thick\n", name);
return false;
}
}
else
{
//Spawn a random bot from bots.cfg if no name given.
TArray<botinfo_t *> BotInfoAvailable;
while (thebot)
{
if (thebot->inuse == BOTINUSE_No)
BotInfoAvailable.Push (thebot);
thebot = thebot->next;
}
if (BotInfoAvailable.Size () == 0)
{
Printf ("Couldn't spawn bot; no bot left in %s\n", BOTFILENAME);
return false;
}
thebot = BotInfoAvailable[pr_botspawn() % BotInfoAvailable.Size ()];
botinfo_t *thebot2 = botinfo;
while (thebot2)
{
if (thebot == thebot2)
break;
botshift++;
thebot2 = thebot2->next;
}
}
thebot->inuse = BOTINUSE_Waiting;
Net_WriteByte (DEM_ADDBOT);
Net_WriteByte (botshift);
{
//Set color.
char concat[512];
strcpy (concat, thebot->info);
if (color == NOCOLOR && bot_next_color < NOCOLOR && bot_next_color >= 0)
{
strcat (concat, colors[bot_next_color]);
}
if (TeamLibrary.IsValidTeam (thebot->lastteam))
{ // Keep the bot on the same team when switching levels
mysnprintf (concat + strlen(concat), countof(concat) - strlen(concat),
"\\team\\%d\n", thebot->lastteam);
}
Net_WriteString (concat);
}
Net_WriteByte(thebot->skill.aiming);
Net_WriteByte(thebot->skill.perfection);
Net_WriteByte(thebot->skill.reaction);
Net_WriteByte(thebot->skill.isp);
//.........这里部分代码省略.........
示例11: GuardNoClient
void GuardNoClient()
{
Printf(Exception,"CCore::Video::GuardNoClient() : no client is attached to a frame window");
}
示例12: R_InitSkins
void R_InitSkins (void)
{
FSoundID playersoundrefs[NUMSKINSOUNDS];
spritedef_t temp;
int sndlumps[NUMSKINSOUNDS];
char key[65];
DWORD intname, crouchname;
size_t i;
int j, k, base;
int lastlump;
int aliasid;
bool remove;
PClassPlayerPawn *basetype, *transtype;
key[sizeof(key)-1] = 0;
i = PlayerClasses.Size () - 1;
lastlump = 0;
for (j = 0; j < NUMSKINSOUNDS; ++j)
{
playersoundrefs[j] = skinsoundnames[j][1];
}
while ((base = Wads.FindLump ("S_SKIN", &lastlump, true)) != -1)
{
// The player sprite has 23 frames. This means that the S_SKIN
// marker needs a minimum of 23 lumps after it.
if (base >= Wads.GetNumLumps() - 23 || base == -1)
continue;
i++;
for (j = 0; j < NUMSKINSOUNDS; j++)
sndlumps[j] = -1;
skins[i].namespc = Wads.GetLumpNamespace (base);
FScanner sc(base);
intname = 0;
crouchname = 0;
remove = false;
basetype = NULL;
transtype = NULL;
// Data is stored as "key = data".
while (sc.GetString ())
{
strncpy (key, sc.String, sizeof(key)-1);
if (!sc.GetString() || sc.String[0] != '=')
{
Printf (PRINT_BOLD, "Bad format for skin %d: %s\n", (int)i, key);
break;
}
sc.GetString ();
if (0 == stricmp (key, "name"))
{
strncpy (skins[i].name, sc.String, 16);
for (j = 0; (size_t)j < i; j++)
{
if (stricmp (skins[i].name, skins[j].name) == 0)
{
mysnprintf (skins[i].name, countof(skins[i].name), "skin%d", (int)i);
Printf (PRINT_BOLD, "Skin %s duplicated as %s\n",
skins[j].name, skins[i].name);
break;
}
}
}
else if (0 == stricmp (key, "sprite"))
{
for (j = 3; j >= 0; j--)
sc.String[j] = toupper (sc.String[j]);
intname = *((DWORD *)sc.String);
}
else if (0 == stricmp (key, "crouchsprite"))
{
for (j = 3; j >= 0; j--)
sc.String[j] = toupper (sc.String[j]);
crouchname = *((DWORD *)sc.String);
}
else if (0 == stricmp (key, "face"))
{
for (j = 2; j >= 0; j--)
skins[i].face[j] = toupper (sc.String[j]);
skins[i].face[3] = '\0';
}
else if (0 == stricmp (key, "gender"))
{
skins[i].gender = D_GenderToInt (sc.String);
}
else if (0 == stricmp (key, "scale"))
{
skins[i].Scale.X = clamp(atof (sc.String), 1./65536, 256.);
skins[i].Scale.Y = skins[i].Scale.X;
}
else if (0 == stricmp (key, "game"))
{
if (gameinfo.gametype == GAME_Heretic)
basetype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_HereticPlayer));
else if (gameinfo.gametype == GAME_Strife)
basetype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_StrifePlayer));
//.........这里部分代码省略.........
示例13: R_InstallSpriteLump
//
// R_InstallSpriteLump
// Local function for R_InitSprites.
//
// [RH] Removed checks for coexistance of rotation 0 with other
// rotations and made it look more like BOOM's version.
//
static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped, spriteframewithrotate *sprtemp, int &maxframe)
{
unsigned rotation;
if (rot >= '0' && rot <= '9')
{
rotation = rot - '0';
}
else if (rot >= 'A')
{
rotation = rot - 'A' + 10;
}
else
{
rotation = 17;
}
if (frame >= MAX_SPRITE_FRAMES || rotation > 16)
{
Printf (TEXTCOLOR_RED"R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->Name.GetChars());
return false;
}
if ((int)frame > maxframe)
maxframe = frame;
if (rotation == 0)
{
// the lump should be used for all rotations
// false=0, true=1, but array initialised to -1
// allows doom to have a "no value set yet" boolean value!
int r;
for (r = 14; r >= 0; r -= 2)
{
if (!sprtemp[frame].Texture[r].isValid())
{
sprtemp[frame].Texture[r] = lump;
if (flipped)
{
sprtemp[frame].Flip |= 1 << r;
}
sprtemp[frame].rotate = false;
}
}
}
else
{
if (rotation <= 8)
{
rotation = (rotation - 1) * 2;
}
else
{
rotation = (rotation - 9) * 2 + 1;
}
if (!sprtemp[frame].Texture[rotation].isValid())
{
// the lump is only used for one rotation
sprtemp[frame].Texture[rotation] = lump;
if (flipped)
{
sprtemp[frame].Flip |= 1 << rotation;
}
sprtemp[frame].rotate = true;
}
}
return true;
}
示例14: M_FindResponseFile
void M_FindResponseFile (void)
{
const int limit = 100; // avoid infinite recursion
int added_stuff = 0;
int i = 1;
while (i < Args->NumArgs())
{
if (Args->GetArg(i)[0] != '@')
{
i++;
}
else
{
char **argv;
char *file = NULL;
int argc = 0;
FILE *handle;
int size;
long argsize = 0;
int index;
// Any more response files after the limit will be removed from the
// command line.
if (added_stuff < limit)
{
// READ THE RESPONSE FILE INTO MEMORY
handle = fopen (Args->GetArg(i) + 1,"rb");
if (!handle)
{ // [RH] Make this a warning, not an error.
Printf ("No such response file (%s)!\n", Args->GetArg(i) + 1);
}
else
{
Printf ("Found response file %s!\n", Args->GetArg(i) + 1);
fseek (handle, 0, SEEK_END);
size = ftell (handle);
fseek (handle, 0, SEEK_SET);
file = new char[size+1];
fread (file, size, 1, handle);
file[size] = 0;
fclose (handle);
argsize = ParseCommandLine (file, &argc, NULL);
}
}
else
{
Printf ("Ignored response file %s.\n", Args->GetArg(i) + 1);
}
if (argc != 0)
{
argv = (char **)M_Malloc (argc*sizeof(char *) + argsize);
argv[0] = (char *)argv + argc*sizeof(char *);
ParseCommandLine (file, NULL, argv);
// Create a new argument vector
DArgs *newargs = new DArgs;
// Copy parameters before response file.
for (index = 0; index < i; ++index)
newargs->AppendArg(Args->GetArg(index));
// Copy parameters from response file.
for (index = 0; index < argc; ++index)
newargs->AppendArg(argv[index]);
// Copy parameters after response file.
for (index = i + 1; index < Args->NumArgs(); ++index)
newargs->AppendArg(Args->GetArg(index));
// Use the new argument vector as the global Args object.
Args = newargs;
if (++added_stuff == limit)
{
Printf("Response file limit of %d hit.\n", limit);
}
}
else
{
// Remove the response file from the Args object
Args->RemoveArg(i);
}
if (file != NULL)
{
delete[] file;
}
}
}
if (added_stuff > 0)
{
// DISPLAY ARGS
Printf ("Added %d response file%s, now have %d command-line args:\n",
added_stuff, added_stuff > 1 ? "s" : "", Args->NumArgs ());
for (int k = 1; k < Args->NumArgs (); k++)
Printf ("%s\n", Args->GetArg (k));
}
}
示例15: M_ScreenShot
void M_ScreenShot (const char *filename)
{
FILE *file;
FString autoname;
bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default
// find a file name to save it to
if (filename == NULL || filename[0] == '\0')
{
size_t dirlen;
autoname = Args->CheckValue("-shotdir");
if (autoname.IsEmpty())
{
autoname = screenshot_dir;
}
dirlen = autoname.Len();
if (dirlen == 0)
{
autoname = M_GetScreenshotsPath();
dirlen = autoname.Len();
}
if (dirlen > 0)
{
if (autoname[dirlen-1] != '/' && autoname[dirlen-1] != '\\')
{
autoname += '/';
}
}
autoname = NicePath(autoname);
CreatePath(autoname);
if (!FindFreeName (autoname, writepcx ? "pcx" : "png"))
{
Printf ("M_ScreenShot: Delete some screenshots\n");
return;
}
}
else
{
autoname = filename;
DefaultExtension (autoname, writepcx ? ".pcx" : ".png");
}
// save the screenshot
const BYTE *buffer;
int pitch;
ESSType color_type;
screen->GetScreenshotBuffer(buffer, pitch, color_type);
if (buffer != NULL)
{
PalEntry palette[256];
if (color_type == SS_PAL)
{
screen->GetFlashedPalette(palette);
}
file = fopen (autoname, "wb");
if (file == NULL)
{
Printf ("Could not open %s\n", autoname.GetChars());
screen->ReleaseScreenshotBuffer();
return;
}
if (writepcx)
{
WritePCXfile(file, buffer, palette, color_type,
screen->GetWidth(), screen->GetHeight(), pitch);
}
else
{
WritePNGfile(file, buffer, palette, color_type,
screen->GetWidth(), screen->GetHeight(), pitch);
}
fclose(file);
screen->ReleaseScreenshotBuffer();
if (!screenshot_quiet)
{
int slash = -1;
if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\");
Printf ("Captured %s\n", autoname.GetChars()+slash+1);
}
}
else
{
if (!screenshot_quiet)
{
Printf ("Could not create screenshot.\n");
}
}
}