Friday, July 3, 2009

CSPSP code fail

So I was working on the clan system for CSPSP yesterday. Since it required changes to the player's model schema (clan was changed from a StringProperty to a ReferenceProperty), I decided to test out the small maintenance mode I had written into CSPSP (or thought I had written). Basically, it should have just given the player an "under maintenance" message when the state was set to STAGE_MAINTENANCE. Unfortunately, I failed at code copy-and-pasting, and this is what happened:
...
else if (mStage == STAGE_SUSPENDED) {
 mRenderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(255,0,0,0));
 gFont->DrawString("[O] Return",SCREEN_WIDTH_2,SCREEN_HEIGHT_F-20,JGETEXT_CENTER);

 gFont->SetScale(1.0f);
 char buffer[128];
 sprintf(buffer,"You are suspended for %i hour(s)",mSuspendHours);
 gFont->DrawString(buffer,SCREEN_WIDTH_2,SCREEN_HEIGHT_2-10,JGETEXT_CENTER);

 strcpy(buffer,"");
 sprintf(buffer,"Reason: %s",mSuspendReason);
 gFont->DrawString(buffer,SCREEN_WIDTH_2,SCREEN_HEIGHT_2+10,JGETEXT_CENTER);
}
else if (mStage == STAGE_SUSPENDED) {
 mRenderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(255,0,0,0));
 gFont->DrawString("[O] Return",SCREEN_WIDTH_2,SCREEN_HEIGHT_F-20,JGETEXT_CENTER);

 gFont->SetScale(1.0f);
 gFont->DrawString("The online system is currently under maintenance.",SCREEN_WIDTH_2,SCREEN_HEIGHT_2,JGETEXT_CENTER);
}
...

yeahhh...should have been mStage == STAGE_MAINTENANCE. Oh well. Means that for about half an hour people were unable to login properly (app engine was probably spitting out errors during that time).

Edit: Also, I hate naming variables. What would you name the reference variable of the Clan a Player leads? leadsClan? clanLeader? thisistheclanthatilead? And how about the date someone joined? joinDate or dateJoined? damnit ):

Edit2: eventually decided on leadsClan :|

No comments:

Post a Comment