Crash
Posted: Tue Aug 02, 2016 8:00 pm
Making a note, Scribble crashed the server by targeting himself on accident and doing a /spawn remove. Probably need to have a client check.
Code: Select all
case COMMAND_SPAWN_REMOVE:{
Spawn* spawn = client->GetPlayer()->GetTarget();
if(spawn && !spawn->IsPlayer()){
if(spawn->GetSpawnLocationID() > 0){
if(database.RemoveSpawnFromSpawnLocation(spawn)){
bool delete_spawn = false;
if(sep && sep->arg[0][0] && sep->IsNumber(0)){
if(atoi(sep->arg[0]) == 1)
delete_spawn = true;
}
if(delete_spawn)
client->GetCurrentZone()->RemoveSpawn(spawn, true, false);
else
spawn->SetSpawnLocationID(0);
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone");
}
else
client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details.");
}
else
client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it");
}
else{
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove");
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone.");
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1");
}
break;
}Thanks for the forward momentum on this !Gangrenous wrote:This fixes it.
Code: Select all
case COMMAND_SPAWN_REMOVE:{ Spawn* spawn = client->GetPlayer()->GetTarget(); if(spawn && !spawn->IsPlayer()){ if(spawn->GetSpawnLocationID() > 0){ if(database.RemoveSpawnFromSpawnLocation(spawn)){ bool delete_spawn = false; if(sep && sep->arg[0][0] && sep->IsNumber(0)){ if(atoi(sep->arg[0]) == 1) delete_spawn = true; } if(delete_spawn) client->GetCurrentZone()->RemoveSpawn(spawn, true, false); else spawn->SetSpawnLocationID(0); client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully removed spawn from zone"); } else client->SimpleMessage(CHANNEL_COLOR_RED, "Error removing spawn, see console window for details."); } else client->SimpleMessage(CHANNEL_COLOR_RED, "This spawn does not have a spawn group associated with it"); } else{ client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Syntax: /spawn remove"); client->SimpleMessage(CHANNEL_COLOR_YELLOW, "This command is used for removing the targeted NPC or Object from the zone."); client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Optionally, you can supply a 1 after the command to despawn it as well. IE /spawn remove 1"); } break; }