Browse Source

Add more LUA debug functions

Patrick Boyd 3 years ago
parent
commit
6785c8d2d5
3 changed files with 25 additions and 2 deletions
  1. 3 0
      .gitmodules
  2. 21 2
      EQ2/source/WorldServer/LuaFunctions.cpp
  3. 1 0
      scripts

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "scripts"]
+	path = scripts
+	url = https://github.com/EQ2Emulator-net/scripts.git

+ 21 - 2
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -2584,12 +2584,25 @@ int EQ2Emu_lua_SetStepComplete(lua_State* state) {
 	if (!lua_interface)
 		return 0;
 	Spawn* player = lua_interface->GetSpawn(state);
+	if (!player || !player->IsPlayer()) {
+		lua_interface->LogError("%s: LUA SetStepComplete command error: player is not valid", lua_interface->GetScriptName(state));
+		return 0;
+	}
 	int32 quest_id = lua_interface->GetInt32Value(state, 2);
+	if (quest_id <= 0) {
+		lua_interface->LogError("%s: LUA SetStepComplete command error: quest_id is not valid", lua_interface->GetScriptName(state));
+		return 0;
+	} else if ((((Player*)player)->player_quests.count(quest_id) <= 0)) {
+		lua_interface->LogError("%s: LUA SetStepComplete command error: player does not have quest", lua_interface->GetScriptName(state));
+		return 0;
+	}
 	int32 step = lua_interface->GetInt32Value(state, 3);
-	if (player && player->IsPlayer() && quest_id > 0 && step > 0 && (((Player*)player)->player_quests.count(quest_id) > 0)) {
+	if (step > 0) {
 		Client* client = player->GetZone()->GetClientBySpawn(player);
 		if (client)
 			client->AddPendingQuestUpdate(quest_id, step);
+	} else {
+		lua_interface->LogError("%s: LUA SetStepComplete command error: step is not valid", lua_interface->GetScriptName(state));
 	}
 	return 0;
 }
@@ -2727,10 +2740,16 @@ int EQ2Emu_lua_HasQuest(lua_State* state) {
 	if (!lua_interface)
 		return 0;
 	Spawn* player = lua_interface->GetSpawn(state);
+	if(!player || !player->IsPlayer()) {
+		lua_interface->LogError("%s: LUA HasQuest command error: player is not valid", lua_interface->GetScriptName(state));
+		return 0;
+	}
 	int32 quest_id = lua_interface->GetInt32Value(state, 2);
-	if (player && player->IsPlayer() && quest_id > 0) {
+	if (quest_id > 0) {
 		lua_interface->SetBooleanValue(state, (((Player*)player)->player_quests.count(quest_id) > 0));
 		return 1;
+	} else {
+		lua_interface->LogError("%s: LUA HasQuest command error: quest_id is not valid", lua_interface->GetScriptName(state));
 	}
 	return 0;
 }

+ 1 - 0
scripts

@@ -0,0 +1 @@
+Subproject commit 9aa1d3e1e255461b03d188109cf5b962143c7a15