summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-09-23 22:37:15 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-09-26 18:09:32 +0200
commit73f1933f94bcadb8c3b3f9763e6afad5f02891f4 (patch)
tree6cd028fcfe3d4a8675f00d5a4a6566d62f3f679a /src/scripting
parent825bc65e0328367c26bebbf68066de3800372f84 (diff)
downloadmanaserv-73f1933f94bcadb8c3b3f9763e6afad5f02891f4.tar.gz
manaserv-73f1933f94bcadb8c3b3f9763e6afad5f02891f4.tar.bz2
manaserv-73f1933f94bcadb8c3b3f9763e6afad5f02891f4.tar.xz
manaserv-73f1933f94bcadb8c3b3f9763e6afad5f02891f4.zip
Store questlog values in the database
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp57
1 files changed, 16 insertions, 41 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index af666bb8..60b3e89c 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -2345,9 +2345,9 @@ static int entity_use_ability(lua_State *s)
return 1;
}
-/** LUA set_questlog_status (being)
- * entity:set_questlog_status(int id, int state, string name,
- * string description[, bool notify = true])
+/** LUA set_questlog (being)
+ * entity:set_questlog(int id, int state, string name,
+ * string description[, bool notify = true])
**
* Sets the questlog status.
*
@@ -2358,28 +2358,18 @@ static int entity_use_ability(lua_State *s)
* * `QUEST_FINISHED`
* * `QUEST_FAILED`
*/
-static int set_questlog_status(lua_State *s)
+static int set_questlog(lua_State *s)
{
const Entity *character = checkCharacter(s, 1);
const int questId = luaL_checkinteger(s, 2);
- const int questState = luaL_checkinteger(s, 3);
+ const QuestState questState = (QuestState)luaL_checkinteger(s, 3);
const char *questTitle = luaL_checkstring(s, 4);
const char *questDescription = luaL_checkstring(s, 5);
const bool questNotification = checkOptionalBool(s, 6, true);
- MessageOut out(GPMSG_QUESTLOG_STATUS);
- out.writeInt16(questId);
- int flags = QUESTLOG_UPDATE_STATE |
- QUESTLOG_UPDATE_TITLE |
- QUESTLOG_UPDATE_DESCRIPTION;
- if (questNotification)
- flags |= QUESTLOG_SHOW_NOTIFICATION;
- out.writeInt8(flags);
- out.writeInt8(questState);
- out.writeString(questTitle);
- out.writeString(questDescription);
-
- character->getComponent<CharacterComponent>()->getClient()->send(out);
+ auto *characterComponent = character->getComponent<CharacterComponent>();
+ characterComponent->setQuestlog(questId, questState, questTitle,
+ questDescription, questNotification);
return 0;
}
@@ -2399,16 +2389,11 @@ static int set_questlog_state(lua_State *s)
{
const Entity *character = checkCharacter(s, 1);
const int questId = luaL_checkinteger(s, 2);
- const int questState = luaL_checkinteger(s, 3);
+ const QuestState questState = (QuestState)luaL_checkinteger(s, 3);
const bool questNotification = checkOptionalBool(s, 4, true);
- MessageOut out(GPMSG_QUESTLOG_STATUS);
- out.writeInt16(questId);
- out.writeInt8(QUESTLOG_UPDATE_STATE |
- questNotification ? QUESTLOG_SHOW_NOTIFICATION : 0);
- out.writeInt8(questState);
-
- character->getComponent<CharacterComponent>()->getClient()->send(out);
+ auto *characterComponent = character->getComponent<CharacterComponent>();
+ characterComponent->setQuestlogState(questId, questState, questNotification);
return 0;
}
@@ -2426,13 +2411,8 @@ static int set_questlog_title(lua_State *s)
const char *questTitle = luaL_checkstring(s, 3);
const bool questNotification = checkOptionalBool(s, 4, true);
- MessageOut out(GPMSG_QUESTLOG_STATUS);
- out.writeInt16(questId);
- out.writeInt8(QUESTLOG_UPDATE_TITLE |
- questNotification ? QUESTLOG_SHOW_NOTIFICATION : 0);
- out.writeString(questTitle);
-
- character->getComponent<CharacterComponent>()->getClient()->send(out);
+ auto *characterComponent = character->getComponent<CharacterComponent>();
+ characterComponent->setQuestlogTitle(questId, questTitle, questNotification);
return 0;
}
@@ -2450,13 +2430,8 @@ static int set_questlog_description(lua_State *s)
const char *questDescription = luaL_checkstring(s, 3);
const bool questNotification = checkOptionalBool(s, 4, true);
- MessageOut out(GPMSG_QUESTLOG_STATUS);
- out.writeInt16(questId);
- out.writeInt8(QUESTLOG_UPDATE_DESCRIPTION |
- questNotification ? QUESTLOG_SHOW_NOTIFICATION : 0);
- out.writeString(questDescription);
-
- character->getComponent<CharacterComponent>()->getClient()->send(out);
+ auto *characterComponent = character->getComponent<CharacterComponent>();
+ characterComponent->setQuestlogDescription(questId, questDescription, questNotification);
return 0;
}
@@ -3553,7 +3528,7 @@ LuaScript::LuaScript():
{ "status_time", entity_get_status_time },
{ "set_status_time", entity_set_status_time },
{ "add_hit_taken", entity_add_hit_taken },
- { "set_questlog_status", set_questlog_status },
+ { "set_questlog", set_questlog },
{ "set_questlog_state", set_questlog_state },
{ "set_questlog_title", set_questlog_title },
{ "set_questlog_description", set_questlog_description },