summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-09-02 23:02:35 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-09-02 23:02:35 +0000
commitbc9bfc17f220f1eaecfe1515ceed6e75df2c30ef (patch)
tree763adac4b3eb2f949377eb1cdfd76debac2a664c /src/map/clif.c
parentc7a6884b345f7f8aaaf65c9529e1cfb8a04609d2 (diff)
downloadhercules-bc9bfc17f220f1eaecfe1515ceed6e75df2c30ef.tar.gz
hercules-bc9bfc17f220f1eaecfe1515ceed6e75df2c30ef.tar.bz2
hercules-bc9bfc17f220f1eaecfe1515ceed6e75df2c30ef.tar.xz
hercules-bc9bfc17f220f1eaecfe1515ceed6e75df2c30ef.zip
Hello! few things.
1) fixed bugreport:6603 - delayed clearunit now makes use of the ERS which is quite convenient for it speeds up due to the previous amount of mallocs that function would spend. 2) added extra debug information to the ERS system (before on any of its warnings we'd go OH MY GOD WHICH ONE OF THEM DID IT!!!), now upon allocation you give it a const, human-readable, name. 3) added support for options in the ERS system to save multiple/redudant processing in battle_delayed_damage and clif_clearunit_delayed and perhaps also in the future. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16736 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 6b03142c3..d368f2955 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11,6 +11,7 @@
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/utils.h"
+#include "../common/ers.h"
#include "map.h"
#include "chrif.h"
@@ -48,6 +49,9 @@
#include <stdarg.h>
#include <time.h>
+/* for clif_clearunit_delayed */
+static struct eri *delay_clearunit_ers;
+
//#define DUMP_UNKNOWN_PACKET
//#define DUMP_INVALID_PACKET
@@ -103,18 +107,15 @@ static inline void RBUFPOS(const uint8* p, unsigned short pos, short* x, short*
{
p += pos;
- if( x )
- {
+ if( x ) {
x[0] = ( ( p[0] & 0xff ) << 2 ) | ( p[1] >> 6 );
}
- if( y )
- {
+ if( y ) {
y[0] = ( ( p[1] & 0x3f ) << 4 ) | ( p[2] >> 4 );
}
- if( dir )
- {
+ if( dir ) {
dir[0] = ( p[2] & 0x0f );
}
}
@@ -124,33 +125,27 @@ static inline void RBUFPOS2(const uint8* p, unsigned short pos, short* x0, short
{
p += pos;
- if( x0 )
- {
+ if( x0 ) {
x0[0] = ( ( p[0] & 0xff ) << 2 ) | ( p[1] >> 6 );
}
- if( y0 )
- {
+ if( y0 ) {
y0[0] = ( ( p[1] & 0x3f ) << 4 ) | ( p[2] >> 4 );
}
- if( x1 )
- {
+ if( x1 ) {
x1[0] = ( ( p[2] & 0x0f ) << 6 ) | ( p[3] >> 2 );
}
- if( y1 )
- {
+ if( y1 ) {
y1[0] = ( ( p[3] & 0x03 ) << 8 ) | ( p[4] >> 0 );
}
- if( sx0 )
- {
+ if( sx0 ) {
sx0[0] = ( p[5] & 0xf0 ) >> 4;
}
- if( sy0 )
- {
+ if( sy0 ) {
sy0[0] = ( p[5] & 0x0f ) >> 0;
}
}
@@ -848,13 +843,12 @@ static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr
{
struct block_list *bl = (struct block_list *)data;
clif_clearunit_area(bl, (clr_type) id);
- aFree(bl);
+ ers_free(delay_clearunit_ers,bl);
return 0;
}
void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int tick)
{
- struct block_list *tbl;
- tbl = (struct block_list*)aMalloc(sizeof (struct block_list));
+ struct block_list *tbl = ers_alloc(delay_clearunit_ers, struct block_list);
memcpy (tbl, bl, sizeof (struct block_list));
add_timer(tick, clif_clearunit_delayed_sub, (int)type, (intptr_t)tbl);
}
@@ -17031,5 +17025,11 @@ int do_init_clif(void) {
add_timer_func_list(clif_clearunit_delayed_sub, "clif_clearunit_delayed_sub");
add_timer_func_list(clif_delayquit, "clif_delayquit");
+ delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR);
+
return 0;
}
+
+void do_final_clif(void) {
+ ers_destroy(delay_clearunit_ers);
+}