From 570234a6eec40917f187a7a437c28c32658509de Mon Sep 17 00:00:00 2001 From: stheno Date: Mon, 5 Sep 2016 05:58:29 -0700 Subject: [PATCH] Implemented some basic commands. broadcast, zone shout, entity say and shout (both npc and pc). Alpha'd the auth handler list so it is easier to read when/if we put more in. --- web_interface/method_handler.cpp | 16 ++++++----- world/remote_call.cpp | 15 ++++++----- zone/remote_call.cpp | 46 ++++++++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/web_interface/method_handler.cpp b/web_interface/method_handler.cpp index 85c6d5712..5ff09c2eb 100644 --- a/web_interface/method_handler.cpp +++ b/web_interface/method_handler.cpp @@ -10,17 +10,19 @@ extern std::map unauthorized_methods; void register_authorized_methods() { authorized_methods["WebInterface.Authorize"] = std::make_pair(0, handle_method_token_auth); - authorized_methods["World.ListZones"] = std::make_pair(10, handle_method_world); + + authorized_methods["World.GetFileContents"] = std::make_pair(10, handle_method_world); authorized_methods["World.GetZoneDetails"] = std::make_pair(10, handle_method_world); - authorized_methods["Zone.Subscribe"] = std::make_pair(10, handle_method_zone); - authorized_methods["Zone.Unsubscribe"] = std::make_pair(10, handle_method_zone); - authorized_methods["Zone.GetInitialEntityPositions"] = std::make_pair(10, handle_method_zone); - authorized_methods["Zone.MoveEntity"] = std::make_pair(10, handle_method_zone); + authorized_methods["World.ListZones"] = std::make_pair(10, handle_method_world); + authorized_methods["World.SaveFileContents"] = std::make_pair(10, handle_method_world); + authorized_methods["Zone.Action"] = std::make_pair(10, handle_method_zone); authorized_methods["Zone.GetEntityAttributes"] = std::make_pair(10, handle_method_zone); + authorized_methods["Zone.GetInitialEntityPositions"] = std::make_pair(10, handle_method_zone); + authorized_methods["Zone.MoveEntity"] = std::make_pair(10, handle_method_zone); authorized_methods["Zone.SetEntityAttribute"] = std::make_pair(10, handle_method_zone); - authorized_methods["World.GetFileContents"] = std::make_pair(10, handle_method_world); - authorized_methods["World.SaveFileContents"] = std::make_pair(10, handle_method_world); + authorized_methods["Zone.Subscribe"] = std::make_pair(10, handle_method_zone); + authorized_methods["Zone.Unsubscribe"] = std::make_pair(10, handle_method_zone); } void register_unauthorized_methods() diff --git a/world/remote_call.cpp b/world/remote_call.cpp index e150b03f7..a97cc8c40 100644 --- a/world/remote_call.cpp +++ b/world/remote_call.cpp @@ -48,17 +48,18 @@ void RemoteCallResponse(const std::string &connection_id, const std::string &req /* World:register_remote_call_handlers */ void register_remote_call_handlers() { - remote_call_methods["World.ListZones"] = handle_rc_list_zones; + remote_call_methods["World.GetFileContents"] = handle_rc_get_file_contents; remote_call_methods["World.GetZoneDetails"] = handle_rc_get_zone_info; - remote_call_methods["Zone.Subscribe"] = handle_rc_relay; - remote_call_methods["Zone.Unsubscribe"] = handle_rc_relay; - remote_call_methods["Zone.GetInitialEntityPositions"] = handle_rc_relay; - remote_call_methods["Zone.MoveEntity"] = handle_rc_relay; + remote_call_methods["World.ListZones"] = handle_rc_list_zones; + remote_call_methods["World.SaveFileContents"] = handle_rc_save_file_contents; + remote_call_methods["Zone.Action"] = handle_rc_relay; remote_call_methods["Zone.GetEntityAttributes"] = handle_rc_relay; + remote_call_methods["Zone.GetInitialEntityPositions"] = handle_rc_relay; + remote_call_methods["Zone.MoveEntity"] = handle_rc_relay; remote_call_methods["Zone.SetEntityAttribute"] = handle_rc_relay; - remote_call_methods["World.GetFileContents"] = handle_rc_get_file_contents; - remote_call_methods["World.SaveFileContents"] = handle_rc_save_file_contents; + remote_call_methods["Zone.Subscribe"] = handle_rc_relay; + remote_call_methods["Zone.Unsubscribe"] = handle_rc_relay; } void handle_rc_list_zones(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector ¶ms) { diff --git a/zone/remote_call.cpp b/zone/remote_call.cpp index 68303cb4f..7a14c43fa 100644 --- a/zone/remote_call.cpp +++ b/zone/remote_call.cpp @@ -78,13 +78,13 @@ void RemoteCall(const std::string &connection_id, const std::string &method, con /* Zone: register_remote_call_handlers */ void register_remote_call_handlers() { - remote_call_methods["Zone.Subscribe"] = handle_rc_subscribe; - remote_call_methods["Zone.Unsubscribe"] = handle_rc_unsubscribe; + remote_call_methods["Zone.Action"] = handle_rc_zone_action; + remote_call_methods["Zone.GetEntityAttributes"] = handle_rc_get_entity_attributes; remote_call_methods["Zone.GetInitialEntityPositions"] = handle_rc_get_initial_entity_positions; remote_call_methods["Zone.MoveEntity"] = handle_rc_move_entity; - remote_call_methods["Zone.GetEntityAttributes"] = handle_rc_get_entity_attributes; remote_call_methods["Zone.SetEntityAttribute"] = handle_rc_set_entity_attribute; - remote_call_methods["Zone.Action"] = handle_rc_zone_action; + remote_call_methods["Zone.Subscribe"] = handle_rc_subscribe; + remote_call_methods["Zone.Unsubscribe"] = handle_rc_unsubscribe; } void handle_rc_subscribe(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector ¶ms) { @@ -231,7 +231,21 @@ void handle_rc_zone_action(const std::string &method, const std::string &connect std::map res; /* Zone Reload Functions */ - if (params[0] == "Repop"){ zone->Repop(); } + if (params[0] == "Repop") { zone->Repop(); } + if (params[0] == "RepopForce") { + zone->Repop(); + //LinkedListIterator iterator(zone->spawn2_list); + //iterator.Reset(); + //while (iterator.MoreElements()) { + // std::string query = StringFormat( + // "DELETE FROM respawn_times WHERE id = %lu AND instance_id = %lu", + // (unsigned long)iterator.GetData()->GetID(), + // (unsigned long)zone->GetInstanceID() + // ); + // auto results = database.QueryDatabase(query); + // iterator.Advance(); + //} + } if (params[0] == "ReloadQuests"){ parse->ReloadQuests(); } /* Zone Visuals Functions */ @@ -279,6 +293,28 @@ void handle_rc_zone_action(const std::string &method, const std::string &connect Mob *ent = entity_list.GetMob(atoi(params[1].c_str())); if (ent){ ent->Kill(); } } + + if (params[0] == "Broadcast") { + worldserver.SendEmoteMessage(0, 0, 15, "God Broadcasts: %s", params[1].c_str()); + } + + if (params[0] == "Shout") { + entity_list.Message(0, 13, "God shouts, '%s'", params[1].c_str()); + } + + if (params[0] == "EntitySay") { + Mob *ent = entity_list.GetMob(atoi(params[1].c_str())); + if (ent) { + ent->Say(params[2].c_str()); + } + } + + if (params[0] == "EntityShout") { + Mob *ent = entity_list.GetMob(atoi(params[1].c_str())); + if (ent) { + ent->Shout(params[2].c_str()); + } + } } /* Server -> Client */