Page 1 of 1

Crash

Posted: Tue Aug 02, 2016 8:00 pm
by Gangrenous
Making a note, Scribble crashed the server by targeting himself on accident and doing a /spawn remove. Probably need to have a client check.

Re: Crash

Posted: Tue Aug 02, 2016 9:41 pm
by Jabantiz
And this is why we need testers, most of us devs would never think to /spawn remove ourselves, should be a simple fix thanks for reporting it.

Re: Crash

Posted: Wed Aug 03, 2016 5:43 am
by Gangrenous
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;
								  }

Re: Crash

Posted: Wed Aug 03, 2016 10:39 am
by Scribble
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;
								  }
Thanks for the forward momentum on this !