Cohsty243 Posted November 20, 2007 Share Posted November 20, 2007 | | \/ Link to comment Share on other sites More sharing options...
DarthDie Posted November 20, 2007 Share Posted November 20, 2007 The only thing in that function that returns 0 (that I can see) is : if ( !f || len >= 4096) { return 0; } What that does is if there is no pointer to a file (ex. no file), or the length of the file is bigger than 4096 (you prolly figured that part out). Link to comment Share on other sites More sharing options...
ensiform Posted November 21, 2007 Share Posted November 21, 2007 What parsing function was this. You should still close the handle if its valid but too large for buffer. Link to comment Share on other sites More sharing options...
Cohsty243 Posted November 21, 2007 Author Share Posted November 21, 2007 I was using "\\"'s but i read somewhere in the code that I should only use just one "\", so that fixed the reading problem. Here's the function again, it crashes at strcat(client->userdb.name, parseBuf); I used Windows Debugger to pinpoint the location. int RP_GetProfile(char filename[MAX_QPATH]) { gentity_t *ent; gclient_t *client; fileHandle_t f; int len; int x; char *msg; char profileInfo[4096]; char parseBuf[4096]; client = ent->client; len = trap_FS_FOpenFile(filename, &f, FS_READ); if ( !f || len >= 2048) { msg = "^2!f || len >= 4096\n"; trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg) ); return 0; } trap_FS_Read(profileInfo, len, f); trap_FS_FCloseFile(f); profileInfo[len] = 0; RP_GetAccountGroup(profileInfo, "profileInfo", profileInfo); //Parse Name if (RP_GetPairedValue(profileInfo, "name", parseBuf)) { /*CRASH HERE-->*/strcat(client->userdb.name, parseBuf); } //Parse password if (RP_GetPairedValue(profileInfo, "pass", parseBuf)) { strcat(client->userdb.pass, parseBuf); } /*//Parse Faction if (RP_GetPairedValue(profileInfo, "faction", parseBuf)) { strcpy(client->userdb.faction, parseBuf); } //Parse Class aka Group if (RP_GetPairedValue(profileInfo, "group", parseBuf)) { strcpy(client->userdb.group, parseBuf); } //Parse subgroup if (RP_GetPairedValue(profileInfo, "subgroup", parseBuf)) { strcpy(client->userdb.subgroup, parseBuf); } //Parse Model if (RP_GetPairedValue(profileInfo, "model", parseBuf)) { strcpy(client->userdb.model, parseBuf); } //Parse Credits if (RP_GetPairedValue(profileInfo, "credits", parseBuf)) { client->userdb.credits = atoi(parseBuf); } //Parse Health if (RP_GetPairedValue(profileInfo, "health", parseBuf)) { client->userdb.health = atoi(parseBuf); } //Parse Armor aka Shield if (RP_GetPairedValue(profileInfo, "shield", parseBuf)) { client->userdb.shield = atoi(parseBuf); } //Parse Weapons if (RP_GetPairedValue(profileInfo, "weapons", parseBuf)) { client->userdb.weapons = atoi(parseBuf); } //Parse Ammo if (RP_GetPairedValue(profileInfo, "ammo", parseBuf)) { client->userdb.ammo = atoi(parseBuf); } //Parse Items if (RP_GetPairedValue(profileInfo, "items", parseBuf)) { client->userdb.items = atoi(parseBuf); }*/ return 1; } Here's that struct for userdb // ===== RP Userdatabase ===== typedef struct { char userid[16]; char name[32]; char pass[32]; char faction[16]; char group[16]; char subgroup[16]; int health; int shield; int credits; char model[32]; int weapons; int items; int ammo; } playerInfoDB_t; // ==== END ==== Link to comment Share on other sites More sharing options...
ensiform Posted November 21, 2007 Share Posted November 21, 2007 Likely due to the fact that parseBuf is larger than userdb.name. I'd use Q_strcat with the size of MAX_NETNAME and change the name sizes to that instead (36) vs 32. Why you using strcat in some cases and strcpy in others? The strcpy instances will fail too btw. strcat is append to string. Also, where is the ent ever set? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.