Ind 945 Posted May 30, 2013 (edited) Hercules casts "Memory Slasher !!" - May 30 PatchMemory Slasher !!Regardless all the fancy features in it, this patch's greatest achievement is smart, clever employment of memory, by looking at our memory usage wisely we've been able to reduce map-server's memory (RAM) usage by more than 2/3, about 183MB of RAM were dropped, while maintaining Hercules outstanding record on performance improvement. Beyond the memory usage drop there is also a significant processing speed improvement which can be noticed during boot, map cache loading which used to account for most of the map-servers boot time no longer exists, its gone, dead, fini, boom! it was replaced by a smart map cache handler that loads its data only when a map is necessary (the data is then kept until shut down), this logic also makes map-server's shut down process a hell lot faster. Instance ReworkAs suggested by the community, this wasnt supposed to be bundled with this commit but the memory usage improvements required me to modify how instances were stored, so I re-wrote part of it to fit the suggestion as well. Instance Functionality/Feature Server may now create instances of any maps regardless of client-side edits, e.g. one can clone prontera and call it "mymapname" (as is best described in the *instance_attachmap script command note) Instances may now be available in 4 distinct ways (as is best described in *instance_create script command note), by nobody (server type instance, to be used with special map names), by a sole character, by a party, or by a guild Script Command Changes *instance_create 2nd param is now called owner_id instead of party_id, and it got a 3rd optional param that defines what kind of owner id it is (when not provided, assumes party_id, for backwards compatibility), available options are (IOT_ stands for INSTANCE OWNER TYPE) IOT_NONE (0), IOT_CHAR (1), IOT_PARTY (2) and IOT_GUILD (3). *instance_destroy no longer autodetects instance id from party id *instance_attachmap now supports a 4th, optional, param, "<new map name>", it will allow you to specify a entirely new map name for the instance (without the need of client-side edits). This option can be best employed when used on a instance of <owner_type> IOT_NONE *instance_detachmap no longer autodetects instance id from party id *instance_id no longer supports any param *instance_set_timeout no longer autodetects instance id from party id *instance_announce no longer autodetects instance id from party id, and to tell it to autodetect from the attached script you must set instance_id param as -1 as opposed to 0 *instance_npcname no longer autodetects instance id from party id *has_instance no longer autodetects instance from party, however it now checks if attached player possesses a instance with same map as has_instance(<param>) checks for *instance_warpall no longer autodetects instance from party Other ChangesInstance IDs (valid ones) are now always >= 0 as opposed to > 0 (update your scripts!) Battlegrounds QueueAs suggested by the community, most of its features were added in this patch, we were unable to finish it though because we lacked some information, we've put our questions in this topic, once our questions are answered we should be able to finish it in a matter of minutes (all the heavy lifting was done in this patch). Arenas They're easily configurable in the new conf/battlegrounds.conf file, it possible to add more arenas by editing the client's lua files/entryqueue/entryqueuelist.lua file Configuration Sample arenas: ({ name: "Tierra Gorge" //must match the name in client files event: "Tierra_BG2::OnPlayerListReady" minLevel: 80 maxLevel: 150 reward: {/* amount of badges awarded on each case */ win: 3 loss: 1 draw: 1 } minPlayers: 6 /* minimum amount of players to start */ maxPlayers: 60 /* maximum amount of players */ minTeamPlayers: 6 /* minimum amount of team members required for a team (party or guild) to join */ delay_var: "Tierra_BG_Tick" /* npc variable name that will store the delay for this match */ maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */},{ name: "KVM (Level 59 and below)" //must match the name in client files event: "KvM03_BG::OnPlayerListReady" minLevel: 1 maxLevel: 59 reward: {/* amount of badges awarded on each case */ win: 1 loss: 0 draw: 0 } minPlayers: 4 /* minimum amount of players to start */ maxPlayers: 60 /* maximum amount of players */ minTeamPlayers: 5 /* minimum amount of team members required for a team (party or guild) to join */ delay_var: "KVM_BG_Tick" /* npc variable name that will store the delay for this match */ maxDuration: 30 /* maximum duration in minutes, if reached game ends and highest score wins (or calls a draw if scores are equal) */}) QueueWe wanted to make the queue as easy to play with as possible, so we've created a whole new set of script commands designed with this purpose. These commands make it easy to create and control queues for anything, games, events, quests, and of course in this case, the battleground's queue. Queue - Script Commands *queue()creates a new queue instance, returns created queue id set .@id,queue(); *queuesize(<queue_id>)returns the amount of entries in queue instance of <queue_id>. set .@length,queuesize(.@queue_id); *queueadd(<queue_id>,<var_id>)adds <var_id> to queue of <queue_id>, returns 1 if <var_id> is already present in the queue, 0 otherwise. queueadd(.@queue_id,.@var_id); *queueremove(<queue_id>,<var_id>)removes <var_id> from queue of <queue_id>, returns 1 if <var_id> is not present in the queue, 0 otherwise. queueremove(.@queue_id,.@var_id); *queueopt(<queue_id>,<optionType>,{Optional <option val>})modifies <queue_id>'s <optionType>, when <option val> is not present, <optionType> is removed from <queue_id>, when present it modifies <queue_id>'s <optionType> with the new <option val> value.Currently 3 options are available, HQO_OnDeath (0), HQO_OnLogout (1), HQO_OnMapChange (2) (the constant names are not final). queueopt(.@queue_id,0,"MyNPC::MyOnQueueMemberDeathEventName");It allows you to hook npc events to be triggered by specific actions that may happen to a player in the queue (when the queue in question is used for account ids) *queuedel(<queue_id>)deletes <queue_id> returns 1 when <queue_id> is not found, 0 otherwise. queuedel(.@queue_id); *queueiterator(<queue_id>)creates a new queue iterator instance, a queue iterator is not a reference to a queue's actual members, it copies the queues members when initialized, this way you can loop through them even if you remove them from the queue set .@it,queueiterator(.@queue_id); *qicheck(<queue_iterator_id>)checks whether there is a next member in the iterator's queue, 1 when it does, 0 otherwise. qicheck(.@queue_iterator_id); *qiget(<queue_iterator_id>)obtains the next member in the iterator's queue, returns the next member's id or 0 when it doesnt exist. for( set .@elem,qiget(.@queue_iterator_id); qicheck(.@queue_iterator_id); set .@elem,qiget(.@queue_iterator_id) ) *qiclear(<queue_iterator_id>)deletes a queue iterator from memory, returns 1 when it fails, 0 otherwise. qiclear(.@queue_iterator_id) Sample Usage: /* say create a queue */set .@id,queue();queueadd(.@id,getcharid(3));/* ... add as many entries ... (no limit) */if( queuesize(.@id) == 999 ) { /* whatever */}/* anywhere in the code */set .@it,queueiterator(.@id);for( set .@elem,qiget(.@it); qicheck(.@it); set .@elem,qiget(.@it) ) { //do anything e.g. /* attachrid .@elem; */ /* mes "ID:"+.@elem; */}qiclear(.@it); Special Thanks To Yommy for providing me with a hell lot of data for the BG Queue, wouldn't have been able to get it to this point without his help. Rosiel for his suggestion on the instance feature Xgear for his help with the network timeout bug mkbu95 for pinpointing the script parser bug All of Hercules Staff for their ideas/suggestions/criticism and support, and for keeping me sane during this memory slashing madness The Future~! This patch sure has taken me away from my usual bug-squashing mode, I'll be going back to my over-10-bug-fix-a-day schedule. We have quite a hell lot planned so this might not last long, make sure to keep an eye on your bug reports for I sure will be replying to them. Link~u! Commit 1 Commit 2 Commit 3 Edited February 7, 2017 by Ridley 21 Renn, Mystery, Jedzkie and 18 others reacted to this Quote Share this post Link to post Share on other sites
mkbu95 34 Posted May 31, 2013 (edited) . Edited September 8 by mkbu95 4 Tragedy, jTynne, kyeme and 1 other reacted to this Quote Share this post Link to post Share on other sites
jTynne 101 Posted May 31, 2013 Yes, yes, yes, yes, yes, yes, yes, yes, yes, yes, yes. Quote Share this post Link to post Share on other sites
Relzz 32 Posted May 31, 2013 Simply the best. To all the haters: No words.. to this, simply AMAZING. Quote Share this post Link to post Share on other sites
thanna 11 Posted May 31, 2013 Simply the best. To all the haters: lol very cool update and very cool sig Quote Share this post Link to post Share on other sites
Yommy 265 Posted May 31, 2013 Super Awesome next we have some atk to figure out <3 Quote Share this post Link to post Share on other sites
Nameless2you 97 Posted May 31, 2013 Awesome work Ind! Now for the very well deserved break! Quote Share this post Link to post Share on other sites
SlashGeeGee 2 Posted May 31, 2013 AWEEEEEEEEEEESOME ! Quote Share this post Link to post Share on other sites
hemagx 69 Posted May 31, 2013 Simply the best. To all the haters: Quote Share this post Link to post Share on other sites
Judas 100 Posted May 31, 2013 woohooo awesome ind! Quote Share this post Link to post Share on other sites
Michi 101 Posted May 31, 2013 Master Ind I would like to say THANK YOUUUU Quote Share this post Link to post Share on other sites
Yuki 6 Posted May 31, 2013 Wow, all of this is amazing <3. Great job! And lol, that animation XD~ Quote Share this post Link to post Share on other sites
Zopokx 7 Posted May 31, 2013 Thanks. You are now my new god Quote Share this post Link to post Share on other sites
jaBote 438 Posted May 31, 2013 OK then, now buying a Raspberry Pi for hosting a RO server at home Quote Share this post Link to post Share on other sites
Nash 2 Posted May 31, 2013 AWESOME RELESE!!!! Quote Share this post Link to post Share on other sites
Judas 100 Posted May 31, 2013 haha yeah, time to host a hercules public server xD Quote Share this post Link to post Share on other sites
Dastgir 1246 Posted May 31, 2013 Finally, Great Job Ind. Quote Share this post Link to post Share on other sites
thanna 11 Posted May 31, 2013 tested this patch and it works fine, hercules can be easily run on low end pc without and problems at all, thanks Ind and hercules community for the great work Quote Share this post Link to post Share on other sites
Mystery 594 Posted June 1, 2013 This is awesome rofl! Quote Share this post Link to post Share on other sites
Xgear 44 Posted June 3, 2013 Just thought about sharing~ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND16659 myserver 15 0 524m 457m 3504 S 3.7 1.4 49:53.60 map-server 3958 myserver 15 0 201m 208m 3700 S 2.0 0.7 2:31.99 map-server Thumbs up to Ind (Y) Thanks! 1 Mystery reacted to this Quote Share this post Link to post Share on other sites