Corrected false error messages, old printfs

netplay.c got a bunch of new LOG_NET debug()s whose effects on performance have not been tested


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@619 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2006-08-23 15:27:20 +00:00
parent bc6a921b84
commit e52dba36cc
14 changed files with 57 additions and 195 deletions

View File

@ -353,7 +353,7 @@ BOOL frameInitialise(HANDLE hInst, // The windows application instance
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_CDROM) != 0)
{
printf("Error: Could not initialise SDL (%s).\n", SDL_GetError());
debug( LOG_ERROR, "Error: Could not initialise SDL (%s).\n", SDL_GetError() );
return FALSE;
}

View File

@ -110,109 +110,5 @@ int PHYSFSEXT_locateCorrectCase(char *buf)
return(locateOneElement(buf) ? 0 : -1);
} /* PHYSFSEXT_locateCorrectCase */
#ifdef TEST_PHYSFSEXT_LOCATECORRECTCASE
int main(int argc, char **argv)
{
int rc;
char buf[128];
PHYSFS_file *f;
if (!PHYSFS_init(argv[0]))
{
fprintf(stderr, "PHYSFS_init(): %s\n", PHYSFS_getLastError());
return(1);
} /* if */
if (!PHYSFS_addToSearchPath(".", 1))
{
fprintf(stderr, "PHYSFS_addToSearchPath(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
} /* if */
if (!PHYSFS_setWriteDir("."))
{
fprintf(stderr, "PHYSFS_setWriteDir(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
} /* if */
if (!PHYSFS_mkdir("/a/b/c"))
{
fprintf(stderr, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
} /* if */
if (!PHYSFS_mkdir("/a/b/C"))
{
fprintf(stderr, "PHYSFS_mkdir(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
} /* if */
f = PHYSFS_openWrite("/a/b/c/x.txt");
PHYSFS_close(f);
if (f == NULL)
{
fprintf(stderr, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
} /* if */
f = PHYSFS_openWrite("/a/b/C/X.txt");
PHYSFS_close(f);
if (f == NULL)
{
fprintf(stderr, "PHYSFS_openWrite(): %s\n", PHYSFS_getLastError());
PHYSFS_deinit();
return(1);
} /* if */
strcpy(buf, "/a/b/c/x.txt");
rc = PHYSFSEXT_locateCorrectCase(buf);
if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
printf("test 1 failed\n");
strcpy(buf, "/a/B/c/x.txt");
rc = PHYSFSEXT_locateCorrectCase(buf);
if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
printf("test 2 failed\n");
strcpy(buf, "/a/b/C/x.txt");
rc = PHYSFSEXT_locateCorrectCase(buf);
if ((rc != 0) || (strcmp(buf, "/a/b/C/X.txt") != 0))
printf("test 3 failed\n");
strcpy(buf, "/a/b/c/X.txt");
rc = PHYSFSEXT_locateCorrectCase(buf);
if ((rc != 0) || (strcmp(buf, "/a/b/c/x.txt") != 0))
printf("test 4 failed\n");
strcpy(buf, "/a/b/c/z.txt");
rc = PHYSFSEXT_locateCorrectCase(buf);
if ((rc != -1) || (strcmp(buf, "/a/b/c/z.txt") != 0))
printf("test 5 failed\n");
strcpy(buf, "/A/B/Z/z.txt");
rc = PHYSFSEXT_locateCorrectCase(buf);
if ((rc != -2) || (strcmp(buf, "/a/b/Z/z.txt") != 0))
printf("test 6 failed\n");
printf("Testing completed.\n");
printf(" If no errors were reported, you're good to go.\n");
PHYSFS_delete("/a/b/c/x.txt");
PHYSFS_delete("/a/b/C/X.txt");
PHYSFS_delete("/a/b/c");
PHYSFS_delete("/a/b/C");
PHYSFS_delete("/a/b");
PHYSFS_delete("/a");
PHYSFS_deinit();
return(0);
} /* main */
#endif
/* end of ignorecase.c ... */

View File

@ -369,7 +369,6 @@ static UBYTE DBug_ExpandString(UBYTE *pub_stringbuffer,
switch (ub_percentchar)
{
case 'a': /* attribute (char) */
printf("Warning (%s:%d): changed char to int, might not work.\n", __FILE__, __LINE__);
ub_newattribute = va_arg(val_arglist, int);
// changed because gcc 4 says it'll crash here
// was ub_newattribute = va_arg(val_arglist, char);
@ -378,8 +377,6 @@ static UBYTE DBug_ExpandString(UBYTE *pub_stringbuffer,
case 'c': /* character */
printf("Warning (%s:%d): changed char to int, might not work.\n", __FILE__, __LINE__);
sprintf((char*)pub_stringbuffer, (const char*)pub_percentstring, va_arg(val_arglist, int));
// changed because gcc 4 says it'll crash here
// was sprintf((char*)pub_stringbuffer, (const char*)pub_percentstring, va_arg(val_arglist, char));

View File

@ -56,7 +56,6 @@ line: TEXT_T QTEXT_T
if (!strresStoreString(psCurrRes, $1, $2))
{
YYABORT;
printf("Hello. I'm the parser.\n");
}
}
;

View File

@ -152,7 +152,7 @@ anim_Create3D( char szPieFileName[], UWORD uwStates,
/* Where does this constant come from, though? - Per */
if ((UDWORD)psFrames==0xcdcdcdcd)
{
printf("bad pointer in Create 3D !!!! -[%s]\n", szPieFileName);
debug( LOG_ERROR, "bad pointer in Create 3D !!!! -[%s]\n", szPieFileName );
}
#endif
uwFrames++;

View File

@ -309,7 +309,7 @@ iBool iV_IMDSave(STRING *filename, iIMDShape *s, BOOL PieIMD)
if (poly->flags & iV_IMD_TEXANIM) {
if (poly->pTexAnim == NULL) {
printf("No TexAnim pointer!\n");
debug( LOG_3D, "No TexAnim pointer!\n" );
} else {
fprintf(fp," %d %d %d %d",
poly->pTexAnim->nFrames,

View File

@ -45,13 +45,13 @@ BOOL check_extension(const char* extension_name) {
if ( extension_name_length == first_extension_length
&& strncmp(extension_name, tmp, first_extension_length) == 0) {
printf("%s is supported.\n", extension_name);
debug( LOG_3D, "%s is supported.\n", extension_name );
return TRUE;
}
tmp += first_extension_length + 1;
}
printf("%s is not supported.\n", extension_name);
debug( LOG_3D, "%s is not supported.\n", extension_name );
return FALSE;
}

View File

@ -75,7 +75,7 @@ iBool iV_VideoMemoryLock(int mode)
_VIDEO_SIZE = size;
_VIDEO_LOCK = TRUE;
printf("vid[VideoMemoryLock] = locked %dK of video memory\n",size/1024);
debug( LOG_3D, "vid[VideoMemoryLock] = locked %dK of video memory\n", size/1024 );
return TRUE;
}

View File

@ -167,7 +167,7 @@ BOOL screenInitialise( UDWORD width, // Display width
exit( 1 );
break;
default:
debug( LOG_ERROR, "Error: Weird bit depth: %i", bpp );
debug( LOG_ERROR, "Error: Unsupported bit depth: %i", bpp );
exit( 1 );
break;
}
@ -182,7 +182,7 @@ BOOL screenInitialise( UDWORD width, // Display width
screen = SDL_SetVideoMode(width, height, bpp, video_flags);
if (!screen) {
printf("Error: SDL_SetVideoMode failed (%s).\n", SDL_GetError());
debug( LOG_ERROR, "Error: SDL_SetVideoMode failed (%s).\n", SDL_GetError() );
return FALSE;
}
}
@ -615,7 +615,7 @@ void screenDoDumpToDiskIfRequired()
return;
}
printf("Saving screenshot %s\n", screendump_filename);
debug( LOG_3D, "Saving screenshot %s\n", screendump_filename );
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);

View File

@ -146,11 +146,7 @@ BOOL NET_recvMessage(NETBUFSOCKET* bs, NETMSG* pMsg)
goto error;
}
#ifdef NET_DEBUG
printf("NETrecvMessage: received message of type %i and size %i.\n",
message->type,
message->size);
#endif
debug( LOG_NET, "NETrecvMessage: received message of type %i and size %i.\n", message->type, message->size );
memcpy(pMsg, message, size);
bs->buffer_start += size;
@ -490,7 +486,7 @@ BOOL NETinit(BOOL bFirstCall)
}
if (SDLNet_Init() == -1) {
printf("SDLNet_Init: %s\n", SDLNet_GetError());
debug( LOG_ERROR, "SDLNet_Init: %s\n", SDLNet_GetError() );
return FALSE;
}
@ -524,9 +520,8 @@ HRESULT NETclose(VOID)
{
unsigned int i;
#ifdef NET_DEBUG
printf("NETclose\n");
#endif
debug( LOG_NET, "NETclose\n" );
NEThaltJoining();
is_server=FALSE;
@ -662,11 +657,10 @@ UDWORD NETgetRecentPacketsRecvd(VOID)
// Send a message to a player, option to guarantee message
BOOL NETsend(NETMSG *msg, DPID player, BOOL guarantee)
{
#ifdef NET_DEBUG
printf("NETsend\n");
#endif
unsigned int size;
debug( LOG_NET, "NETsend\n" );
if(!NetPlay.bComms)
{
return TRUE;
@ -710,11 +704,10 @@ printf("NETsend\n");
// broadcast a message to all players.
BOOL NETbcast(NETMSG *msg, BOOL guarantee)
{
#ifdef NET_DEBUG
printf("NETbcast\n");
#endif
unsigned int size;
debug( LOG_NET, "NETbcast\n" );
if(!NetPlay.bComms)
{
return TRUE;
@ -759,9 +752,8 @@ printf("NETbcast\n");
// Check if a message is a system message
BOOL NETprocessSystemMessage(NETMSG * pMsg)
{
#ifdef NET_DEBUG
printf("NETprocessSystemMessage\n");
#endif
debug( LOG_NET, "NETprocessSystemMessage\n" );
switch (pMsg->type) {
case MSG_PLAYER_INFO: {
NET_PLAYER* pi = (NET_PLAYER*)(pMsg->body);
@ -962,9 +954,8 @@ receive_message:
BOOL NETsetupTCPIP(LPVOID *addr, char * machine)
{
#ifdef NET_DEBUG
printf("NETsetupTCPIP\n");
#endif
debug( LOG_NET, "NETsetupTCPIP\n" );
if ( hostname != NULL
&& hostname != master_server) {
free(hostname);
@ -1113,18 +1104,14 @@ void NETregisterServer(int state) {
switch(state) {
case 1: {
if(SDLNet_ResolveHost(&ip, master_server, MASTER_SERVER_PORT) == -1) {
printf("NETregisterServer: couldn't resolve master server (%s): %s\n",
master_server,
SDLNet_GetError());
debug( LOG_ERROR, "NETregisterServer: couldn't resolve master server (%s): %s\n", master_server, SDLNet_GetError() );
server_not_there = 1;
return;
}
if(!rs_socket) rs_socket = SDLNet_TCP_Open(&ip);
if(rs_socket == NULL) {
printf("NETregisterServer: Cannot connect to master server (%s): %s\n",
master_server,
SDLNet_GetError());
debug( LOG_ERROR, "NETregisterServer: Cannot connect to master server (%s): %s\n", master_server, SDLNet_GetError() );
server_not_there = 1;
return;
}
@ -1159,8 +1146,7 @@ void NETallowJoining() {
if (tmp_socket_set == NULL) {
tmp_socket_set = SDLNet_AllocSocketSet(MAX_TMP_SOCKETS+1);
if (tmp_socket_set == NULL) {
printf("Couldn't create socket set: %s\n",
SDLNet_GetError());
debug( LOG_ERROR, "Couldn't create socket set: %s\n", SDLNet_GetError() );
return;
}
SDLNet_TCP_AddSocket(tmp_socket_set, tcp_socket);
@ -1249,12 +1235,11 @@ BOOL NEThostGame(LPSTR SessionName, LPSTR PlayerName,
DWORD one, DWORD two, DWORD three, DWORD four,
UDWORD plyrs) // # of players.
{
#ifdef NET_DEBUG
printf("NEThostGame\n");
#endif
IPaddress ip;
unsigned int i;
debug( LOG_NET, "NEThostGame\n" );
if(!NetPlay.bComms)
{
NetPlay.dpidPlayer = 1;
@ -1264,8 +1249,7 @@ printf("NEThostGame\n");
}
if(SDLNet_ResolveHost(&ip, NULL, WARZONE_NET_PORT) == -1) {
printf("NEThostGame: couldn't resolve master self: %s\n",
SDLNet_GetError());
debug( LOG_ERROR, "NEThostGame: couldn't resolve master self: %s\n", SDLNet_GetError() );
return FALSE;
}
@ -1277,8 +1261,7 @@ printf("NEThostGame\n");
if(!socket_set) socket_set = SDLNet_AllocSocketSet(MAX_CONNECTED_PLAYERS);
if (socket_set == NULL) {
printf("Couldn't create socket set: %s\n",
SDLNet_GetError());
debug( LOG_ERROR, "Couldn't create socket set: %s\n", SDLNet_GetError() );
return FALSE;
}
for (i = 0; i < MAX_CONNECTED_PLAYERS; ++i) {
@ -1318,9 +1301,8 @@ printf("NEThostGame\n");
// Stop the dplay interface from accepting more players.
BOOL NEThaltJoining(VOID)
{
#ifdef NET_DEBUG
printf("NEThaltJoining\n");
#endif
debug( LOG_NET, "NEThaltJoining\n" );
allow_joining = FALSE;
return TRUE;
@ -1332,14 +1314,12 @@ printf("NEThaltJoining\n");
BOOL NETfindGame(BOOL async) /// may (not) want to use async here...
{
static UDWORD gamecount = 0, gamesavailable;
#ifdef NET_DEBUG
printf("NETfindGame\n");
#endif
IPaddress ip;
char buffer[sizeof(GAMESTRUCT)*2];
GAMESTRUCT* tmpgame = (GAMESTRUCT*)buffer;
debug( LOG_NET, "NETfindGame\n" );
gamecount = 0;
NetPlay.games[0].desc.dwSize = 0;
NetPlay.games[0].desc.dwCurrentPlayers = 0;
@ -1354,9 +1334,7 @@ printf("NETfindGame\n");
if (SDLNet_ResolveHost(&ip, hostname, (hostname == master_server) ? MASTER_SERVER_PORT
: WARZONE_NET_PORT) == -1) {
printf("NETfindGame: couldn't resolve hostname (%s): %s\n",
hostname,
SDLNet_GetError());
debug( LOG_ERROR, "NETfindGame: couldn't resolve hostname (%s): %s\n", hostname, SDLNet_GetError() );
return FALSE;
}
@ -1366,14 +1344,13 @@ printf("NETfindGame\n");
tcp_socket = SDLNet_TCP_Open(&ip);
if (tcp_socket == NULL) {
printf("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
debug( LOG_ERROR, "SDLNet_TCP_Open: %s\n", SDLNet_GetError() );
return FALSE;
}
socket_set = SDLNet_AllocSocketSet(1);
if (socket_set == NULL) {
printf("Couldn't create socket set: %s\n",
SDLNet_GetError());
debug( LOG_ERROR, "Couldn't create socket set: %s\n", SDLNet_GetError() );
return FALSE;
}
SDLNet_TCP_AddSocket(socket_set, tcp_socket);
@ -1386,9 +1363,7 @@ printf("NETfindGame\n");
gamesavailable=(UDWORD)buffer[0];
}
#ifdef NET_DEBUG
printf("receiving info of %d game(s)\n", gamesavailable);
#endif
debug( LOG_NET, "receiving info of %d game(s)\n", gamesavailable );
do {
if ( SDLNet_CheckSockets(socket_set, 1000) > 0
@ -1424,14 +1399,12 @@ printf("NETfindGame\n");
// Functions used to setup and join games.
BOOL NETjoinGame(UDWORD gameNumber, LPSTR playername)
{
#ifdef NET_DEBUG
printf("NETjoinGame gameNumber=%d\n", gameNumber);
#endif
char* name;
IPaddress ip;
char buffer[sizeof(GAMESTRUCT)*2];
GAMESTRUCT* tmpgame = (GAMESTRUCT*)buffer;
debug( LOG_NET, "NETjoinGame gameNumber=%d\n", gameNumber );
NETclose(); // just to be sure :)
@ -1441,9 +1414,7 @@ printf("NETjoinGame gameNumber=%d\n", gameNumber);
hostname = strdup(NetPlay.games[gameNumber].desc.host);
if(SDLNet_ResolveHost(&ip, hostname, WARZONE_NET_PORT) == -1) {
printf("NETjoinGame: couldn't resolve hostname (%s): %s\n",
hostname,
SDLNet_GetError());
debug( LOG_ERROR, "NETjoinGame: couldn't resolve hostname (%s): %s\n", hostname, SDLNet_GetError() );
return FALSE;
}
@ -1453,14 +1424,13 @@ printf("NETjoinGame gameNumber=%d\n", gameNumber);
tcp_socket = SDLNet_TCP_Open(&ip);
if (tcp_socket == NULL) {
printf("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
debug( LOG_ERROR, "SDLNet_TCP_Open: %s\n", SDLNet_GetError() );
return FALSE;
}
socket_set = SDLNet_AllocSocketSet(1);
if (socket_set == NULL) {
printf("Couldn't create socket set: %s\n",
SDLNet_GetError());
debug( LOG_ERROR, "Couldn't create socket set: %s\n", SDLNet_GetError() );
return FALSE;
}
SDLNet_TCP_AddSocket(socket_set, tcp_socket);

View File

@ -143,7 +143,7 @@ rpl_open(char* filename) {
break;
default:
rpl->sound_decoder = rpl_decode_sound_unknown;
printf("Unknown sound format %i\n", tmp);
debug( LOG_VIDEO, "Unknown sound format %i\n", tmp );
break;
}
rpl->current_sound_frame = 0;
@ -191,7 +191,7 @@ rpl_open(char* filename) {
for (i = 0; i < rpl->nb_chunks; ++i) {
readline(f, buf, len);
if (sscanf(buf, "%i,%i;%i", &rpl->chunks[i].offset, &rpl->chunks[i].video_size, &rpl->chunks[i].audio_size) != 3) {
printf("Error in chunk catalog\n");
debug( LOG_VIDEO, "Error in chunk catalog\n" );
goto error;
}
@ -223,7 +223,7 @@ unsigned int rpl_decode_sound_unknown(RPL* rpl, short* buffer, unsigned int buff
char* tmp;
PHYSFS_file * out;
printf("Saving unknown sound stream to file\n");
debug( LOG_VIDEO, "Saving unknown sound stream to file\n" );
for (i = 0; i < rpl->nb_chunks; ++i) {
total_audio_size += rpl->chunks[i].audio_size;
}

View File

@ -64,7 +64,7 @@ void seq_start_sound(RPL* s) {
BOOL seq_SetSequenceForBuffer(char* filename, int startTime, PERF_MODE perfMode)
{
#ifdef DUMMY_VIDEO
printf("seq_SetSequenceForBuffer %s -> novideo.rpl\n", filename);
debug( LOG_VIDEO, "seq_SetSequenceForBuffer %s -> novideo.rpl\n", filename );
filename = "novideo.rpl";
#endif
if (current_sequence != NULL) {
@ -86,7 +86,7 @@ BOOL seq_SetSequenceForBuffer(char* filename, int startTime, PERF_MODE perfMode)
BOOL seq_SetSequence(char* filename, int startTime, char* lpBF, PERF_MODE perfMode)
{
#ifdef DUMMY_VIDEO
printf("seq_SetSequence %s -> novideo.rpl\n", filename);
debug( LOG_VIDEO, "seq_SetSequence %s -> novideo.rpl\n", filename );
filename = "novideo.rpl";
#endif
if (current_sequence != NULL) {
@ -104,7 +104,7 @@ BOOL seq_SetSequence(char* filename, int startTime, char* lpBF, PERF_MODE perfMo
int seq_ClearMovie(void)
{
printf("seq_ClearMovie\n");
debug( LOG_VIDEO, "seq_ClearMovie\n" );
if (current_sequence != NULL) {
rpl_close(current_sequence);
current_sequence = NULL;
@ -162,7 +162,7 @@ BOOL seq_RefreshVideoBuffers(void)
BOOL seq_ShutDown(void)
{
printf("seq_ShutDown\n");
debug( LOG_VIDEO, "seq_ShutDown\n" );
if (current_sequence != NULL) {
if (seq_sound == TRUE) {
alSourceStop(seq_source);

View File

@ -438,7 +438,7 @@ BOOL gwGenerateLinkGates(void)
ASSERT( apEquivZones != NULL,
"gwGenerateLinkGates: no zone equivalence table" );
debug( LOG_ERROR, "Generating water link Gateways...." );
debug( LOG_NEVER, "Generating water link Gateways...." );
for(zone=1; zone<gwNumZones; zone += 1)
{
@ -459,7 +459,7 @@ BOOL gwGenerateLinkGates(void)
}
}
debug( LOG_ERROR, "Done\n" );
debug( LOG_NEVER, "Done\n" );
return TRUE;
}

View File

@ -3587,13 +3587,13 @@ void moveUpdateGroundModel(DROID *psDroid, SDWORD speed, SDWORD direction)
droidGetNaybors(psDroid);
#ifdef DEBUG_DRIVE_SPEED
if(psDroid == driveGetDriven()) printf("%d ",speed);
if(psDroid == driveGetDriven()) debug( LOG_NEVER, "%d ", speed );
#endif
moveCheckFinalWaypoint( psDroid, &speed );
#ifdef DEBUG_DRIVE_SPEED
if(psDroid == driveGetDriven()) printf("%d ",speed);
if(psDroid == driveGetDriven()) debug( LOG_NEVER, "%d ", speed );
#endif
// moveUpdateDroidDirection( psDroid, &speed, direction, TRACKED_SPIN_ANGLE,
@ -3602,7 +3602,7 @@ if(psDroid == driveGetDriven()) printf("%d ",speed);
spinSpeed, turnSpeed, &iDroidDir, &fSpeed );
#ifdef DEBUG_DRIVE_SPEED
if(psDroid == driveGetDriven()) printf("%d ",speed);
if(psDroid == driveGetDriven()) debug( LOG_NEVER, "%d ", speed );
#endif
fNormalSpeed = moveCalcNormalSpeed( psDroid, fSpeed, iDroidDir,
@ -3613,7 +3613,7 @@ if(psDroid == driveGetDriven()) printf("%d ",speed);
fPerpSpeed, iDroidDir );
#ifdef DEBUG_DRIVE_SPEED
if(psDroid == driveGetDriven()) printf("%d\n",speed);
if(psDroid == driveGetDriven()) debug( LOG_NEVER, "%d\n", speed );
#endif
// if (psDroid->direction != psDroid->sMove.dir)