From: <wel...@us...> - 2008-10-28 13:56:40
|
Revision: 2296 http://planeshift.svn.sourceforge.net/planeshift/?rev=2296&view=rev Author: weltall2 Date: 2008-10-28 12:18:30 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Added a /disablequest command which can change toggle a quest status from enabled to disabled and viceversa, and if the flag save is defined it will also save the new status to database Modified Paths: -------------- trunk/data/help.xml trunk/docs/history.txt trunk/src/server/adminmanager.cpp trunk/src/server/adminmanager.h trunk/src/server/database/mysql/command_access.sql trunk/src/server/database/mysql/server_options.sql trunk/src/server/database/mysql/upgrade_schema.sql Modified: trunk/data/help.xml =================================================================== --- trunk/data/help.xml 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/data/help.xml 2008-10-28 12:18:30 UTC (rev 2296) @@ -428,6 +428,9 @@ <topic name="/divorce">/divorce name Divorce a character from another one if they are married.</topic> + <topic name="/disablequest">/disablequest questname [save] + +This function will toggle the quest from enabled to disabled status and viceversa, if the save flag is used the new status will also be saved in the database.</topic> <topic name="/event">Administer events. To create a new event, a GM should enter: /event create [name] [description] Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/docs/history.txt 2008-10-28 12:18:30 UTC (rev 2296) @@ -1,6 +1,9 @@ *** 2008-10-28 by Stefano Angeleri - Restricted mana restoring disable only when resurrecting from death realm fixing FS#2299 - Keep dying in death realm for unlimited mana +- Added a /disablequest command which can change toggle a quest status from enabled + to disabled and viceversa, and if the flag save is defined it will also save the new + status to database *** 2008-10-28 by Andrew Dai - Moved NPCTypes to use a hash instead of a binary tree. Also removed globals Modified: trunk/src/server/adminmanager.cpp =================================================================== --- trunk/src/server/adminmanager.cpp 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/src/server/adminmanager.cpp 2008-10-28 12:18:30 UTC (rev 2296) @@ -1069,6 +1069,12 @@ player = words[1]; return true; } + else if (command == "/disablequest") //disables/enables quests + { + text = words[1]; //name of the quest + subCmd = words[2]; //save = save to db + return true; + } return false; } @@ -1448,6 +1454,10 @@ { CheckTarget(msg, data, targetobject, client); } + else if (data.command == "/disablequest") + { + DisableQuest(me, msg, data, client); + } } void AdminManager::HandleLoadQuest(psAdminCmdMessage& msg, AdminCmdData& data, Client* client) @@ -7879,3 +7889,44 @@ if(targetobject) //just to be sure psserver->SendSystemInfo(client->GetClientNum(),"Targeted: %s", targetobject->GetName()); } + +void AdminManager::DisableQuest(MsgEntry* me, psAdminCmdMessage& msg, AdminCmdData& data, Client *client ) +{ + psQuest * quest = CacheManager::GetSingleton().GetQuestByName(data.text); //get the quest associated by name + + if(!quest) + { + psserver->SendSystemError(client->GetClientNum(), "Unable to find the requested quest."); + return; + } + + quest->Active(!quest->Active()); //invert the status of the quest: if enabled, disable it, if disabled, enable it + if(data.subCmd == "save") //if the subcmd is save we save this also on the database + { + if(!Valid(client->GetSecurityLevel(), "save quest disable", me->clientnum)) //check if the client has the correct rights to do this + { + psserver->SendSystemInfo(client->GetClientNum(),"You can't change the active status of quests: the quest status was changed only temporarily."); + return; + } + + Result flags(db->Select("SELECT flags FROM quests WHERE id=%u", quest->GetID())); //get the current flags from the database + if (!flags.IsValid() || flags.Count() == 0) //there were results? + { + psserver->SendSystemError(client->GetClientNum(), "Unable to find the quest in the database."); + return; + } + + uint flag = flags[0].GetUInt32("flags"); //get the flags and assign them to a variable + + if(quest->Active()) //if active assign the flag + flag |= PSQUEST_DISABLED_QUEST; + else //else remove the flag + flag &= ~PSQUEST_DISABLED_QUEST; + + //save the flags to the db + db->CommandPump("UPDATE quests SET flags=%u WHERE id=%u", flag, quest->GetID()); + } + + //tell the user that everything went fine + psserver->SendSystemInfo(client->GetClientNum(),"The quest %s was %s successfully", quest->GetName(), quest->Active() ? "enabled" : "disabled"); +} Modified: trunk/src/server/adminmanager.h =================================================================== --- trunk/src/server/adminmanager.h 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/src/server/adminmanager.h 2008-10-28 12:18:30 UTC (rev 2296) @@ -383,6 +383,14 @@ * @param client The GM client the command came from. */ void CheckTarget(psAdminCmdMessage& msg, AdminCmdData& data, gemObject* targetobject , Client *client); + + /** @brief Allows to disable/enable quests temporarily (server cache) or definitely (database) + * + * @param me The incoming message from the GM + * @param msg The cracked command message. + * @param client The GM client the command came from. + */ + void DisableQuest(MsgEntry* me, psAdminCmdMessage& msg, AdminCmdData& data, Client *client ); /** @brief Adds a petition under the passed user's name to the 'petitions' table in the database. * Modified: trunk/src/server/database/mysql/command_access.sql =================================================================== --- trunk/src/server/database/mysql/command_access.sql 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/src/server/database/mysql/command_access.sql 2008-10-28 12:18:30 UTC (rev 2296) @@ -49,6 +49,7 @@ INSERT INTO command_group_assignment VALUES( "/reload", 30 ); INSERT INTO command_group_assignment VALUES( "/runscript", 30 ); INSERT INTO command_group_assignment VALUES( "/loadquest", 30 ); +INSERT INTO command_group_assignment VALUES( "save quest disable", 30 ); # GM5 and above INSERT INTO command_group_assignment VALUES( "/killnpc", 30 ); @@ -61,6 +62,8 @@ INSERT INTO command_group_assignment VALUES( "/modify", 25 ); INSERT INTO command_group_assignment VALUES( "/key", 30 ); INSERT INTO command_group_assignment VALUES( "/key", 25 ); +INSERT INTO command_group_assignment VALUES( "/disablequest", 30 ); +INSERT INTO command_group_assignment VALUES( "/disablequest", 25 ); INSERT INTO command_group_assignment VALUES( "move unpickupables/spawns", 30 ); INSERT INTO command_group_assignment VALUES( "move unpickupables/spawns", 25 ); Modified: trunk/src/server/database/mysql/server_options.sql =================================================================== --- trunk/src/server/database/mysql/server_options.sql 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/src/server/database/mysql/server_options.sql 2008-10-28 12:18:30 UTC (rev 2296) @@ -28,7 +28,7 @@ # Dumping data for table server_options # -INSERT INTO `server_options` VALUES ('db_version','1200'); +INSERT INTO `server_options` VALUES ('db_version','1201'); INSERT INTO `server_options` VALUES ('game_time','15:00'); INSERT INTO `server_options` VALUES ('game_date','100-1-1'); INSERT INTO `server_options` VALUES ('standard_motd','This is the message of the day from server_options table.'); Modified: trunk/src/server/database/mysql/upgrade_schema.sql =================================================================== --- trunk/src/server/database/mysql/upgrade_schema.sql 2008-10-28 06:39:16 UTC (rev 2295) +++ trunk/src/server/database/mysql/upgrade_schema.sql 2008-10-28 12:18:30 UTC (rev 2296) @@ -1016,6 +1016,12 @@ UPDATE sectors SET non_transient_objects = 1 WHERE name = 'NPCRoom3'; UPDATE `server_options` SET `option_value`='1200' WHERE `option_name`='db_version'; +#### 1201 - Stefano Angeleri - added a /disablequest command to disable/enable quests +INSERT INTO command_group_assignment VALUES( "save quest disable", 30 ); +INSERT INTO command_group_assignment VALUES( "/disablequest", 30 ); +INSERT INTO command_group_assignment VALUES( "/disablequest", 25 ); +UPDATE `server_options` SET `option_value`='1201' WHERE `option_name`='db_version'; + # Insert your upgrade before this line. Remember when you set a new db_version # to update the server_options.sql file and update psserver.cpp as well. # This to ensure that everything is working if you use the create_all.sql to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |