aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximius <none@none>2009-09-19 16:01:08 -0700
committermaximius <none@none>2009-09-19 16:01:08 -0700
commitec054272e1ded02f7dadfa84b5f0f93e53f52fc8 (patch)
treed04ba34739a7cf7eaed4fb4e2f98b8f5ef8711a8
parent22869c7a47315c9f1568b14c4d960bf1d3f345c4 (diff)
*GO - Southfury Moonstone script, from SD2, patch by manuel
*Fix Auctionhouse CPU usage during item expire check, by MrSmite --HG-- branch : trunk
-rw-r--r--sql/FULL/world_scripts_full.sql1
-rw-r--r--sql/updates/5701_world_scripts.sql (renamed from sql/updates/5701_world.sql)0
-rw-r--r--sql/updates/5702_world_scripts.sql2
-rw-r--r--src/bindings/scripts/scripts/world/go_scripts.cpp29
-rw-r--r--src/game/AuctionHouseMgr.cpp18
-rw-r--r--src/game/AuctionHouseMgr.h6
6 files changed, 53 insertions, 3 deletions
diff --git a/sql/FULL/world_scripts_full.sql b/sql/FULL/world_scripts_full.sql
index 006a10f93ff..3d877c99e27 100644
--- a/sql/FULL/world_scripts_full.sql
+++ b/sql/FULL/world_scripts_full.sql
@@ -1158,6 +1158,7 @@ UPDATE `creature_template` SET `ScriptName`='npc_elder_kuruti' WHERE `entry`=181
UPDATE `creature_template` SET `ScriptName`='npc_mortog_steamhead' WHERE `entry`=23373;
UPDATE `creature_template` SET `ScriptName`='npc_kayra_longmane' WHERE `entry`=17969;
UPDATE `creature_template` SET `ScriptName`='npc_timothy_daniels' WHERE `entry`=18019;
+UPDATE `gameobject_template` SET `ScriptName`='go_southfury_moonstone' WHERE `entry`=185566;
/* ZUL'AMAN */
UPDATE `instance_template` SET `script`='instance_zulaman' WHERE `map`=568;
diff --git a/sql/updates/5701_world.sql b/sql/updates/5701_world_scripts.sql
index 6560085346f..6560085346f 100644
--- a/sql/updates/5701_world.sql
+++ b/sql/updates/5701_world_scripts.sql
diff --git a/sql/updates/5702_world_scripts.sql b/sql/updates/5702_world_scripts.sql
new file mode 100644
index 00000000000..df6fc98b5c2
--- /dev/null
+++ b/sql/updates/5702_world_scripts.sql
@@ -0,0 +1,2 @@
+
+UPDATE `gameobject_template` SET `ScriptName`='go_southfury_moonstone' WHERE `entry`=185566;
diff --git a/src/bindings/scripts/scripts/world/go_scripts.cpp b/src/bindings/scripts/scripts/world/go_scripts.cpp
index e9107bec4dc..0aa59f689e1 100644
--- a/src/bindings/scripts/scripts/world/go_scripts.cpp
+++ b/src/bindings/scripts/scripts/world/go_scripts.cpp
@@ -31,6 +31,7 @@ go_ethereum_prison
go_ethereum_stasis
go_sacred_fire_of_life
go_shrine_of_the_birds
+go_southfury_moonstone
go_field_repair_bot_74A
go_orb_of_command
go_resonite_cask
@@ -349,6 +350,29 @@ bool GOHello_go_shrine_of_the_birds(Player* pPlayer, GameObject* pGo)
}
/*######
+## go_southfury_moonstone
+######*/
+
+enum
+{
+ NPC_RIZZLE = 23002,
+ SPELL_BLACKJACK = 39865, //stuns player
+ SPELL_SUMMON_RIZZLE = 39866
+
+};
+
+bool GOHello_go_southfury_moonstone(Player* pPlayer, GameObject* pGo)
+{
+ //implicitTarget=48 not implemented as of writing this code, and manual summon may be just ok for our purpose
+ //pPlayer->CastSpell(pPlayer,SPELL_SUMMON_RIZZLE,false);
+
+ if (Creature* pCreature = pPlayer->SummonCreature(NPC_RIZZLE, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0))
+ pCreature->CastSpell(pPlayer,SPELL_BLACKJACK,false);
+
+ return false;
+}
+
+/*######
## go_tele_to_dalaran_crystal
######*/
@@ -461,6 +485,11 @@ void AddSC_go_scripts()
newscript->RegisterSelf();
newscript = new Script;
+ newscript->Name = "go_southfury_moonstone";
+ newscript->pGOHello = &GOHello_go_southfury_moonstone;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
newscript->Name="go_tablet_of_madness";
newscript->pGOHello = &GOHello_go_tablet_of_madness;
newscript->RegisterSelf();
diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp
index 85bc815efd1..2edaa3f374c 100644
--- a/src/game/AuctionHouseMgr.cpp
+++ b/src/game/AuctionHouseMgr.cpp
@@ -537,8 +537,16 @@ void AuctionHouseObject::Update()
{
time_t curTime = sWorld.GetGameTime();
///- Handle expired auctions
- AuctionEntryMap::iterator next;
- for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end();itr = next)
+
+ // reset next if at end of map
+ if (next == AuctionsMap.end())
+ next = AuctionsMap.begin();
+
+ uint32 loopBreaker = 0;
+
+ // Initialize itr with next. next is stored for future calls to Update() after
+ // 50 items are checked
+ for (AuctionEntryMap::const_iterator itr = next; itr != AuctionsMap.end(); itr = next)
{
next = itr;
++next;
@@ -565,6 +573,12 @@ void AuctionHouseObject::Update()
delete itr->second;
RemoveAuction(itr->first);
}
+
+ // only check 50 items per update to not peg the CPU
+ ++loopBreaker;
+
+ if (loopBreaker > 50)
+ break;
}
}
diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h
index 2a106cf20f9..32635af43e8 100644
--- a/src/game/AuctionHouseMgr.h
+++ b/src/game/AuctionHouseMgr.h
@@ -76,7 +76,8 @@ struct AuctionEntry
class AuctionHouseObject
{
public:
- AuctionHouseObject() {}
+ // Initialize storage
+ AuctionHouseObject() { next = AuctionsMap.begin(); }
~AuctionHouseObject()
{
for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
@@ -118,6 +119,9 @@ class AuctionHouseObject
private:
AuctionEntryMap AuctionsMap;
+
+ // storage for "next" auction item for next Update()
+ AuctionEntryMap::const_iterator next;
};
class AuctionHouseMgr