@@ -238,7 +238,7 @@ const char *GetString(int d) {
238238 else
239239 return StringTable[d];
240240}
241- static void SaveStatsToFile (char *filename);
241+ static void SaveStatsToFile (const char *filename);
242242static void DetermineScore (int precord_num, int column_num, char *buffer, int buffer_size);
243243static void ShowStatBitmap (int precord_num, int column_num, int x, int y, int w, int h, uint8_t alpha_to_use);
244244
@@ -352,7 +352,6 @@ void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_us
352352
353353 DMFCBase->GameInit (CTFNumOfTeams);
354354 DLLCreateStringTable (" CTF.str" , &StringTable, &StringTableSize);
355- DLLmprintf (0 , " %d strings loaded from string table\n " , StringTableSize);
356355 if (!StringTableSize) {
357356 *all_ok = 0 ;
358357 return ;
@@ -568,6 +567,11 @@ void DLLFUNCCALL DLLGameClose() {
568567 }
569568}
570569
570+ void DLLFUNCCALL DLLLoggerInit (plog::Severity severity, plog::IAppender* appender) {
571+ plog::init (severity, appender);
572+ LOG_DEBUG << " Logger for module initialized" ;
573+ }
574+
571575// ///////////////////////////////////////////////////////////
572576// DMFC Overrides
573577
@@ -782,7 +786,7 @@ void OnClientLevelStart(void) {
782786 if ((flagid != -1 ) && (goalroom >= 0 ) && (goalroom <= DMFCBase->GetHighestRoomIndex ()) &&
783787 (!ROOMNUM_OUTSIDE (goalroom)) && (dRooms[goalroom].used )) {
784788 // Safe to create the flag
785- DLLmprintf ( 0 , " Creating %s Flag\n " , DMFCBase->GetTeamString (i));
789+ LOG_INFO. printf ( " Creating %s Flag" , DMFCBase->GetTeamString (i));
786790 DLLComputeRoomCenter (&vpos, &dRooms[goalroom]);
787791 objnum = DLLObjCreate (OBJ_POWERUP, flagid, goalroom, &vpos, NULL , OBJECT_HANDLE_NONE);
788792 DLLMultiSendObject (&dObjects[objnum], 0 , true );
@@ -1027,7 +1031,7 @@ void OnClientCollide(uint8_t *data) {
10271031 if (DMFCBase->GetScoreLimit (&killgoal)) {
10281032 if (TeamScores[pteam] >= killgoal) {
10291033 // That's all she wrote for this level
1030- DLLmprintf ( 0 , " OnClientCollide:Kill Goal Reached!\n " ) ;
1034+ LOG_INFO << " OnClientCollide:Kill Goal Reached!" ;
10311035 DMFCBase->EndLevel ();
10321036 }
10331037 }
@@ -1380,11 +1384,11 @@ void OnPLRInterval(void) {
13801384quick_exit:;
13811385}
13821386
1383- void SaveStatsToFile (char *filename) {
1387+ void SaveStatsToFile (const char *filename) {
13841388 CFILE *file;
13851389 DLLOpenCFILE (&file, filename, " wt" );
13861390 if (!file) {
1387- DLLmprintf ( 0 , " Unable to open output file\n " ) ;
1391+ LOG_WARNING << " Unable to open output file" ;
13881392 return ;
13891393 }
13901394
@@ -2158,15 +2162,15 @@ bool AddFlagToPlayer(int pnum, int team, int flagobjnum) {
21582162
21592163 if (!ret) {
21602164 // couldn't attach the flag
2161- mprintf ( 0 , " CTF: COULDN'T ATTACH FLAG TO PLAYER, DELETING\n " ) ;
2165+ LOG_WARNING << " CTF: COULDN'T ATTACH FLAG TO PLAYER, DELETING" ;
21622166 // tell the clients to remove this flag
21632167 DLLSetObjectDeadFlag (&dObjects[flagobjnum], true , false );
21642168 }
21652169 }
21662170
21672171 if (flagobjnum == -1 ) {
21682172 // there was an error creating the flag...not good
2169- mprintf ( 0 , " CTF: Couldn't create/unhash flag for attachment\n " ) ;
2173+ LOG_WARNING << " CTF: Couldn't create/unhash flag for attachment" ;
21702174 DMFCBase->DisconnectMe ();
21712175 return false ;
21722176 }
@@ -2426,7 +2430,7 @@ void ReceiveGameState(uint8_t *data) {
24262430
24272431 if (our_objnum == -1 ) {
24282432 // fatal error
2429- mprintf ( 0 , " CTF: Local Objnums don't match server objnums\n " ) ;
2433+ LOG_ERROR << " CTF: Local Objnums don't match server objnums" ;
24302434 ChildFlags[i] = OBJECT_HANDLE_NONE;
24312435 DMFCBase->DisconnectMe ();
24322436 } else {
@@ -2435,7 +2439,7 @@ void ReceiveGameState(uint8_t *data) {
24352439 AddFlagToPlayer (HasFlag[i], i, our_objnum);
24362440 else {
24372441 // hmm, HasFlag doesn't match ChildFlags
2438- mprintf ( 0 , " CTF: HasFlag doesn't match ChildFlags!!!!\n " ) ;
2442+ LOG_WARNING << " CTF: HasFlag doesn't match ChildFlags!!!!" ;
24392443 ChildFlags[i] = OBJECT_HANDLE_NONE;
24402444 }
24412445 }
@@ -2455,7 +2459,7 @@ int GetFlagCountForPlayer(int pnum) {
24552459 // 1st check the pnum, make sure it is OK, is it isn't, return 0
24562460 if (pnum < 0 || pnum >= DLLMAX_PLAYERS) {
24572461 // invalid player number, return 0 flags
2458- mprintf ( 0 , " CTF: Invalid PNUM passed to GetFlagCountForPlayer()\n " ) ;
2462+ LOG_WARNING << " CTF: Invalid PNUM passed to GetFlagCountForPlayer()" ;
24592463 return 0 ;
24602464 }
24612465
@@ -2477,7 +2481,7 @@ uint8_t GetFlagMaskForPlayer(int pnum) {
24772481 // 1st check the pnum, make sure it is OK, if it isn't, return 0, meaning no flags
24782482 if (pnum < 0 || pnum >= DLLMAX_PLAYERS) {
24792483 // invalid player number, return 0 flags
2480- mprintf ( 0 , " CTF: Invalid PNUM passed to GetFlagMaskForPlayer()\n " ) ;
2484+ LOG_WARNING << " CTF: Invalid PNUM passed to GetFlagMaskForPlayer()" ;
24812485 return 0 ;
24822486 }
24832487
@@ -2505,34 +2509,34 @@ bool GivePlayerFlag(int pnum, uint8_t team) {
25052509 // 1st check the player num, make sure it is valid
25062510 if (!DMFCBase->CheckPlayerNum (pnum)) {
25072511 // not a valid player
2508- mprintf ( 0 , " CTF: Invalid pnum passed to GivePlayerFlag()\n " ) ;
2512+ LOG_WARNING << " CTF: Invalid pnum passed to GivePlayerFlag()" ;
25092513 return false ;
25102514 }
25112515
25122516 // 2nd check to make sure the team given is valid, and not our own team
25132517 if (team >= CTFNumOfTeams) {
25142518 // not a valid team
2515- mprintf ( 0 , " CTF: Invalid team passed to GivePlayerFlag() (team>=CTFNumOfTeams)\n " ) ;
2519+ LOG_WARNING << " CTF: Invalid team passed to GivePlayerFlag() (team>=CTFNumOfTeams)" ;
25162520 return false ;
25172521 }
25182522 if (team == DMFCBase->GetPlayerTeam (pnum)) {
25192523 // we can't add a flag of the same team to a player
2520- mprintf ( 0 , " CTF: In GivePlayerFlag(), trying to add a player's home team flag\n " ) ;
2524+ LOG_INFO << " CTF: In GivePlayerFlag(), trying to add a player's home team flag" ;
25212525 return false ;
25222526 }
25232527
25242528 // 3rd, make sure no one else currently has this flag
25252529 // we'll check our HasFlags[] first
25262530 if (HasFlag[team] != -1 ) {
25272531 // hmm, we have someone listed as already having this flag...odd
2528- mprintf ( 0 , " CTF: In GivePlayerFlag(), trying to add a flag, but we see someone else should already have it\n " ) ;
2532+ LOG_WARNING << " CTF: In GivePlayerFlag(), trying to add a flag, but we see someone else should already have it" ;
25292533 int player = HasFlag[team];
25302534 if (DMFCBase->CheckPlayerNum (player)) {
25312535 // this player is in the game...
25322536 // make sure this player doesn't have the flag in his inventory
25332537 while (DLLInvCheckItem (player, OBJ_POWERUP, FlagIDs[team])) {
25342538 // we have it listed that he does
2535- mprintf ( 0 , " CTF: In GivePlayerFlag(), we detected the flag in someone elses inventory\n " ) ;
2539+ LOG_WARNING << " CTF: In GivePlayerFlag(), we detected the flag in someone elses inventory" ;
25362540 // remove all the flags that this player has of this team...very weird
25372541 DLLInvRemove (player, OBJ_POWERUP, FlagIDs[team]);
25382542 SetColoredBalls (player, false );
@@ -2546,7 +2550,7 @@ bool GivePlayerFlag(int pnum, uint8_t team) {
25462550 // reset this value of the array
25472551 HasFlag[team] = -1 ;
25482552 if (DMFCBase->GetLocalRole () != LR_SERVER) {
2549- mprintf ( 0 , " CTF: Game must be out of sync, requesting game state\n " ) ;
2553+ LOG_WARNING << " CTF: Game must be out of sync, requesting game state" ;
25502554 DMFCBase->RequestGameState ();
25512555 }
25522556 }
@@ -2559,7 +2563,7 @@ bool GivePlayerFlag(int pnum, uint8_t team) {
25592563
25602564 // remove all the flags the player has
25612565 while (DLLInvCheckItem (player, OBJ_POWERUP, FlagIDs[team])) {
2562- mprintf ( 0 , " CTF: In GivePlayerFlag(), detected a flag in a stranger's inventory\n " ) ;
2566+ LOG_WARNING << " CTF: In GivePlayerFlag(), detected a flag in a stranger's inventory" ;
25632567 DLLInvRemove (player, OBJ_POWERUP, FlagIDs[team]);
25642568 SetColoredBalls (player, false );
25652569 // check to see if the player had a flag attached to him
@@ -2579,7 +2583,7 @@ bool GivePlayerFlag(int pnum, uint8_t team) {
25792583 // so we got here and added a flag to the player, now we need to attach the flag to the player
25802584 if (!AddFlagToPlayer (pnum, team)) {
25812585 // there was an error adding the flag,,,,ack!
2582- mprintf ( 0 , " CTF: In GivePlayerFlag(), couldn't attach the flag to the player\n " ) ;
2586+ LOG_WARNING << " CTF: In GivePlayerFlag(), couldn't attach the flag to the player" ;
25832587 }
25842588 }
25852589
@@ -2590,18 +2594,18 @@ bool GivePlayerFlag(int pnum, uint8_t team) {
25902594void LoseFlagForPlayer (int pnum, uint8_t team, bool remove_from_inven) {
25912595 // 1st check the player number
25922596 if (pnum < 0 || pnum >= DLLMAX_PLAYERS) {
2593- mprintf ( 0 , " CTF:Invalid pnum passed to LoseFlagForPlayer()\n " ) ;
2597+ LOG_WARNING << " CTF:Invalid pnum passed to LoseFlagForPlayer()" ;
25942598 return ;
25952599 }
25962600
25972601 // 2nd check the team number
25982602 if (team >= CTFNumOfTeams) {
2599- mprintf ( 0 , " CTF:Invalid team passed to LoseFlagForPlayer()\n " ) ;
2603+ LOG_WARNING << " CTF:Invalid team passed to LoseFlagForPlayer()" ;
26002604 return ;
26012605 }
26022606
26032607 if (team == DMFCBase->GetPlayerTeam (pnum)) {
2604- mprintf ( 0 , " CTF:Invalid team passed to LoseFlagForPlayer()...same team as player\n " ) ;
2608+ LOG_WARNING << " CTF:Invalid team passed to LoseFlagForPlayer()...same team as player" ;
26052609 return ;
26062610 }
26072611
0 commit comments