- Minor changes to ers.

- Removed unused/hardly used cbasetypes typedefs.
- Updated txt-converter's makefile to include utils.o

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9473 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
FlavioJS 2006-12-12 15:24:20 +00:00
parent e3d9258754
commit 129e97d6c9
18 changed files with 90 additions and 166 deletions

View File

@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/12/12 2006/12/12
* Minor changes to ers.
* Removed unused/hardly used cbasetypes typedefs.
* Updated txt-converter's makefile to include utils.o [FlavioJS]
* Updated npc_event_dequeue to free up your current npc information, and * Updated npc_event_dequeue to free up your current npc information, and
not just the npc_id. not just the npc_id.
* Modified the skill damage packet and the knockback packets to mimic aegis * Modified the skill damage packet and the knockback packets to mimic aegis

View File

@ -53,35 +53,6 @@
#endif #endif
//////////////////////////////////////////////////////////////////////////
// useful typedefs
//////////////////////////////////////////////////////////////////////////
#define HAVE_UCHAR
typedef unsigned char uchar;
typedef signed char schar;
typedef signed short sshort;
#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H)
typedef unsigned short ushort;
#endif
typedef signed int sint; // don't use (only for ie. scanf)
#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H)
typedef unsigned int uint; // don't use
#endif
typedef signed long slong; // don't use (only for ie. file-io)
#ifndef _SYS_TYPES_H
typedef unsigned long ulong; // don't use
#endif
#ifndef WIN32
typedef char* pchar;
typedef unsigned char* puchar;
#endif
typedef const char* cchar;
typedef void* ptr;
typedef int* pint;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// typedefs to compensate type size change from 32bit to 64bit // typedefs to compensate type size change from 32bit to 64bit
// MS implements LLP64 model, normal unix does LP64, // MS implements LLP64 model, normal unix does LP64,
@ -235,7 +206,7 @@ typedef unsigned long long uint64;
////////////////////////////// //////////////////////////////
// boolean types for C // boolean types for C
typedef int bool; typedef char bool;
#define false (1==0) #define false (1==0)
#define true (1==1) #define true (1==1)

View File

@ -186,7 +186,7 @@ typedef struct db {
unsigned int free_max; unsigned int free_max;
unsigned int free_lock; unsigned int free_lock;
// Other // Other
ERInterface nodes; ERS nodes;
DBComparator cmp; DBComparator cmp;
DBHasher hash; DBHasher hash;
DBReleaser release; DBReleaser release;
@ -2165,7 +2165,7 @@ DBInterface db_alloc(const char *file, int line, DBType type, DBOptions options,
db->free_max = 0; db->free_max = 0;
db->free_lock = 0; db->free_lock = 0;
/* Other */ /* Other */
db->nodes = ers_new((uint32)sizeof(struct dbn)); db->nodes = ers_new(sizeof(struct dbn));
db->cmp = db_default_cmp(type); db->cmp = db_default_cmp(type);
db->hash = db_default_hash(type); db->hash = db_default_hash(type);
db->release = db_default_release(type, options); db->release = db_default_release(type, options);

View File

@ -159,7 +159,7 @@ typedef enum {
typedef union { typedef union {
int i; int i;
unsigned int ui; unsigned int ui;
unsigned char *str; unsigned char *str;//## TODO change to 'const char *'
} DBKey; } DBKey;
/** /**

View File

@ -50,15 +50,14 @@
* ERS_BLOCK_ENTRIES - Number of entries in each block. * * ERS_BLOCK_ENTRIES - Number of entries in each block. *
* ERS_ROOT_SIZE - Maximum number of root entry managers. * * ERS_ROOT_SIZE - Maximum number of root entry managers. *
* ERLinkedList - Structure of a linked list of reusable entries. * * ERLinkedList - Structure of a linked list of reusable entries. *
* ERSystem - Class of an entry manager. * * ERS_impl - Class of an entry manager. *
* ers_root - Array of root entry managers. * * ers_root - Array of root entry managers. *
* ers_num - Number of root entry managers in the array. * * ers_num - Number of root entry managers in the array. *
\*****************************************************************************/ \*****************************************************************************/
/** /**
* Number of entries in each block. * Number of entries in each block.
* @private * @see #ers_obj_alloc_entry(ERS eri)
* @see #ers_obj_alloc_entry(ERInterface eri)
*/ */
#define ERS_BLOCK_ENTRIES 4096 #define ERS_BLOCK_ENTRIES 4096
@ -74,7 +73,7 @@
* Linked list of reusable entries. * Linked list of reusable entries.
* The minimum size of the entries is the size of this structure. * The minimum size of the entries is the size of this structure.
* @private * @private
* @see ERSystem#reuse * @see ERS_impl#reuse
*/ */
typedef struct ers_ll { typedef struct ers_ll {
struct ers_ll *next; struct ers_ll *next;
@ -92,7 +91,7 @@ typedef struct ers_ll {
* @param size Size of the entries of the manager * @param size Size of the entries of the manager
* @private * @private
*/ */
typedef struct ers { typedef struct ers_impl {
/** /**
* Public interface of the entry manager. * Public interface of the entry manager.
@ -101,61 +100,45 @@ typedef struct ers {
* @param entry_size Return the size of the entries of this manager * @param entry_size Return the size of the entries of this manager
* @param destroy Destroy this instance of the manager * @param destroy Destroy this instance of the manager
* @public * @public
* @see #ERSystem
* @see common\ers.h#ERInterface
*/ */
struct eri eri; struct eri vtable;
/** /**
* Linked list of reusable entries. * Linked list of reusable entries.
* @private
* @see #ERSystem
*/ */
ERLinkedList reuse; ERLinkedList reuse;
/** /**
* Array with blocks of entries. * Array with blocks of entries.
* @private
* @see #ERSystem
*/ */
uint8 **blocks; uint8 **blocks;
/** /**
* Number of unused entries in the last block. * Number of unused entries in the last block.
* @private
* @see #ERSystem
*/ */
uint32 free; uint32 free;
/** /**
* Number of blocks in the array. * Number of blocks in the array.
* @private
* @see #ERSystem
*/ */
uint32 num; uint32 num;
/** /**
* Current maximum capacity of the array. * Current maximum capacity of the array.
* @private
* @see #ERSystem
*/ */
uint32 max; uint32 max;
/** /**
* Destroy lock. * Destroy lock.
* @private
* @see #ERSystem
*/ */
uint32 destroy; uint32 destroy;
/** /**
* Size of the entries of the manager. * Size of the entries of the manager.
* @private
* @see #ERSystem
*/ */
uint32 size; size_t size;
} *ERSystem; } *ERS_impl;
/** /**
* Root array with entry managers. * Root array with entry managers.
@ -164,7 +147,7 @@ typedef struct ers {
* @see #ERS_ROOT_SIZE * @see #ERS_ROOT_SIZE
* @see #ers_num * @see #ers_num
*/ */
static ERSystem ers_root[ERS_ROOT_SIZE]; static ERS_impl ers_root[ERS_ROOT_SIZE];
/** /**
* Number of entry managers in the root array. * Number of entry managers in the root array.
@ -176,7 +159,7 @@ static ERSystem ers_root[ERS_ROOT_SIZE];
static uint32 ers_num = 0; static uint32 ers_num = 0;
/*****************************************************************************\ /*****************************************************************************\
* (2) Protected functions. * * (2) Object functions. *
* ers_obj_alloc_entry - Allocate an entry from the manager. * * ers_obj_alloc_entry - Allocate an entry from the manager. *
* ers_obj_free_entry - Free an entry allocated from the manager. * * ers_obj_free_entry - Free an entry allocated from the manager. *
* ers_obj_entry_size - Return the size of the entries of the manager. * * ers_obj_entry_size - Return the size of the entries of the manager. *
@ -188,19 +171,17 @@ static uint32 ers_num = 0;
* If there are reusable entries available, it reuses one instead. * If there are reusable entries available, it reuses one instead.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @return An entry * @return An entry
* @protected
* @see #ERS_BLOCK_ENTRIES * @see #ERS_BLOCK_ENTRIES
* @see #ERLinkedList * @see #ERLinkedList
* @see #ERSystem * @see ERS_impl::vtable#alloc
* @see common\ers.h\ERInterface#alloc(ERInterface)
*/ */
static void *ers_obj_alloc_entry(ERInterface self) static void *ers_obj_alloc_entry(ERS self)
{ {
ERSystem obj = (ERSystem)self; ERS_impl obj = (ERS_impl)self;
void *ret; void *ret;
if (obj == NULL) { if (obj == NULL) {
ShowError("ers_obj_alloc_entry: NULL object, aborting entry allocation.\n"); ShowError("ers::alloc : NULL object, aborting entry allocation.\n");
return NULL; return NULL;
} }
@ -213,11 +194,11 @@ static void *ers_obj_alloc_entry(ERInterface self)
} else { // allocate a new block } else { // allocate a new block
if (obj->num == obj->max) { // expand the block array if (obj->num == obj->max) { // expand the block array
if (obj->max == UINT32_MAX) { // No more space for blocks if (obj->max == UINT32_MAX) { // No more space for blocks
ShowFatalError("ers_obj_alloc_entry: maximum number of blocks reached, increase ERS_BLOCK_ENTRIES.\n" ShowFatalError("ers::alloc : maximum number of blocks reached, increase ERS_BLOCK_ENTRIES.\n"
"exiting the program...\n"); "exiting the program...\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
obj->max = (obj->max<<2) +3; // = obj->max*4 +3; - overflow won't happen obj->max = (obj->max*4)+3; // left shift bits '11' - overflow won't happen
RECREATE(obj->blocks, uint8 *, obj->max); RECREATE(obj->blocks, uint8 *, obj->max);
} }
CREATE(obj->blocks[obj->num], uint8, obj->size*ERS_BLOCK_ENTRIES); CREATE(obj->blocks[obj->num], uint8, obj->size*ERS_BLOCK_ENTRIES);
@ -234,22 +215,20 @@ static void *ers_obj_alloc_entry(ERInterface self)
* Freeing such an entry can lead to unexpected behaviour. * Freeing such an entry can lead to unexpected behaviour.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @param entry Entry to be freed * @param entry Entry to be freed
* @protected
* @see #ERLinkedList * @see #ERLinkedList
* @see #ERSystem * @see ERS_impl#reuse
* @see ERSystem#reuse * @see ERS_impl::vtable#free
* @see common\ers.h\ERInterface#free(ERInterface,void *)
*/ */
static void ers_obj_free_entry(ERInterface self, void *entry) static void ers_obj_free_entry(ERS self, void *entry)
{ {
ERSystem obj = (ERSystem)self; ERS_impl obj = (ERS_impl)self;
ERLinkedList reuse; ERLinkedList reuse;
if (obj == NULL) { if (obj == NULL) {
ShowError("ers_obj_free_entry: NULL object, aborting entry freeing.\n"); ShowError("ers::free : NULL object, aborting entry freeing.\n");
return; return;
} else if (entry == NULL) { } else if (entry == NULL) {
ShowError("ers_obj_free_entry: NULL entry, nothing to free.\n"); ShowError("ers::free : NULL entry, nothing to free.\n");
return; return;
} }
@ -262,17 +241,15 @@ static void ers_obj_free_entry(ERInterface self, void *entry)
* Return the size of the entries allocated from this manager. * Return the size of the entries allocated from this manager.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @return Size of the entries of this manager in bytes * @return Size of the entries of this manager in bytes
* @protected * @see ERS_impl#size
* @see #ERSystem * @see ERS_impl::vtable#entry_size
* @see ERSystem#size
* @see common\ers.h\ERInterface#enty_size(ERInterface)
*/ */
static uint32 ers_obj_entry_size(ERInterface self) static uint32 ers_obj_entry_size(ERS self)
{ {
ERSystem obj = (ERSystem)self; ERS_impl obj = (ERS_impl)self;
if (obj == NULL) { if (obj == NULL) {
ShowError("ers_obj_entry_size: NULL object, returning 0.\n"); ShowError("ers::entry_size : NULL object, returning 0.\n");
return 0; return 0;
} }
@ -285,19 +262,18 @@ static uint32 ers_obj_entry_size(ERInterface self)
* When destroying the manager a warning is shown if the manager has * When destroying the manager a warning is shown if the manager has
* missing/extra entries. * missing/extra entries.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @protected
* @see #ERLinkedList * @see #ERLinkedList
* @see #ERSystem * @see ERS_impl::vtable#destroy
* @see common\ers.h\ERInterface#destroy(ERInterface)
*/ */
static void ers_obj_destroy(ERInterface self) static void ers_obj_destroy(ERS self)
{ {
ERSystem obj = (ERSystem)self; ERS_impl obj = (ERS_impl)self;
ERLinkedList reuse,old; ERLinkedList reuse,old;
uint32 i, count; uint32 i;
uint32 count;
if (obj == NULL) { if (obj == NULL) {
ShowError("ers_obj_destroy: NULL object, aborting instance destruction.\n"); ShowError("ers::destroy: NULL object, aborting instance destruction.\n");
return; return;
} }
@ -334,14 +310,14 @@ static void ers_obj_destroy(ERInterface self)
} }
} }
if (count) { // missing entries if (count) { // missing entries
ShowWarning("ers_obj_destroy: %u entries missing (possible double free), continuing destruction (entry size=%u).", ShowWarning("ers::destroy : %u entries missing (possible double free), continuing destruction (entry size=%u).",
count, obj->size); count, obj->size);
} else if (reuse) { // extra entries } else if (reuse) { // extra entries
while (reuse && count != UINT32_MAX) { while (reuse && count != UINT32_MAX) {
count++; count++;
reuse = reuse->next; reuse = reuse->next;
} }
ShowWarning("ers_obj_destroy: %u extra entries found, continuing destruction (entry size=%u).", ShowWarning("ers::destroy : %u extra entries found, continuing destruction (entry size=%u).",
count, obj->size); count, obj->size);
} }
// destroy the entry manager // destroy the entry manager
@ -369,17 +345,13 @@ static void ers_obj_destroy(ERInterface self)
* ERS_ALIGNED that is greater or equal to size is what's actually used. * ERS_ALIGNED that is greater or equal to size is what's actually used.
* @param The requested size of the entry in bytes * @param The requested size of the entry in bytes
* @return Interface of the object * @return Interface of the object
* @public * @see #ERS_impl
* @see #ERSystem
* @see #ers_root * @see #ers_root
* @see #ers_num * @see #ers_num
* @see common\ers.h#ERInterface
* @see common\ers.h\ERInterface#destroy(ERInterface)
* @see common\ers.h#ers_new_(uint32)
*/ */
ERInterface ers_new(uint32 size) ERS ers_new(size_t size)
{ {
ERSystem obj; ERS_impl obj;
uint32 i; uint32 i;
if (size == 0) { if (size == 0) {
@ -398,7 +370,7 @@ ERInterface ers_new(uint32 size)
if (obj->size == size) { if (obj->size == size) {
// found a manager that handles the entry size // found a manager that handles the entry size
obj->destroy++; obj->destroy++;
return &obj->eri; return &obj->vtable;
} }
} }
// create a new manager to handle the entry size // create a new manager to handle the entry size
@ -407,12 +379,12 @@ ERInterface ers_new(uint32 size)
"exiting the program...\n"); "exiting the program...\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
obj = (ERSystem)aMalloc(sizeof(struct ers)); obj = (ERS_impl)aMalloc(sizeof(struct ers_impl));
// Public interface // Public interface
obj->eri.alloc = ers_obj_alloc_entry; obj->vtable.alloc = ers_obj_alloc_entry;
obj->eri.free = ers_obj_free_entry; obj->vtable.free = ers_obj_free_entry;
obj->eri.entry_size = ers_obj_entry_size; obj->vtable.entry_size = ers_obj_entry_size;
obj->eri.destroy = ers_obj_destroy; obj->vtable.destroy = ers_obj_destroy;
// Block reusage system // Block reusage system
obj->reuse = NULL; obj->reuse = NULL;
obj->blocks = NULL; obj->blocks = NULL;
@ -423,7 +395,7 @@ ERInterface ers_new(uint32 size)
// Properties // Properties
obj->size = size; obj->size = size;
ers_root[ers_num++] = obj; ers_root[ers_num++] = obj;
return &obj->eri; return &obj->vtable;
} }
/** /**
@ -432,18 +404,20 @@ ERInterface ers_new(uint32 size)
* The number of entries are checked and a warning is shown if extra reusable * The number of entries are checked and a warning is shown if extra reusable
* entries are found. * entries are found.
* The extra entries are included in the count of reusable entries. * The extra entries are included in the count of reusable entries.
* @public
* @see #ERLinkedList * @see #ERLinkedList
* @see #ERSystem * @see #ERS_impl
* @see #ers_root * @see #ers_root
* @see #ers_num * @see #ers_num
* @see common\ers.h#ers_report(void)
*/ */
void ers_report(void) void ers_report(void)
{ {
uint32 i, j, used, reusable, extra; uint32 i;
uint32 j;
uint32 used;
uint32 reusable;
uint32 extra;
ERLinkedList reuse; ERLinkedList reuse;
ERSystem obj; ERS_impl obj;
// Root system report // Root system report
ShowMessage(CL_BOLD"Entry Reusage System report:\n"CL_NORMAL); ShowMessage(CL_BOLD"Entry Reusage System report:\n"CL_NORMAL);
@ -506,16 +480,15 @@ void ers_report(void)
* The use of this is NOT recommended. * The use of this is NOT recommended.
* It should only be used in extreme situations to make shure all the memory * It should only be used in extreme situations to make shure all the memory
* allocated by this system is released. * allocated by this system is released.
* @public * @see #ERS_impl
* @see #ERSystem
* @see #ers_root * @see #ers_root
* @see #ers_num * @see #ers_num
* @see common\ers.h#ers_force_destroy_all(void)
*/ */
void ers_force_destroy_all(void) void ers_force_destroy_all(void)
{ {
uint32 i, j; uint32 i;
ERSystem obj; uint32 j;
ERS_impl obj;
for (i = 0; i < ers_num; i++) { for (i = 0; i < ers_num; i++) {
obj = ers_root[i]; obj = ers_root[i];

View File

@ -36,7 +36,6 @@
* @version 0.1 - Initial version * * @version 0.1 - Initial version *
* @author Flavio @ Amazon Project * * @author Flavio @ Amazon Project *
* @encoding US-ASCII * * @encoding US-ASCII *
* @see common#ers.c *
\*****************************************************************************/ \*****************************************************************************/
#ifndef _ERS_H_ #ifndef _ERS_H_
#define _ERS_H_ #define _ERS_H_
@ -47,7 +46,7 @@
* (1) All public parts of the Entry Reusage System. * * (1) All public parts of the Entry Reusage System. *
* DISABLE_ERS - Define to disable this system. * * DISABLE_ERS - Define to disable this system. *
* ERS_ALIGNED - Alignment of the entries in the blocks. * * ERS_ALIGNED - Alignment of the entries in the blocks. *
* ERInterface - Interface of the entry manager. * * ERS - Entry manager. *
* ers_new - Allocate an instance of an entry manager. * * ers_new - Allocate an instance of an entry manager. *
* ers_report - Print a report about the current state. * * ers_report - Print a report about the current state. *
* ers_force_destroy_all - Force the destruction of all the managers. * * ers_force_destroy_all - Force the destruction of all the managers. *
@ -57,7 +56,6 @@
* Define this to disable the Entry Reusage System. * Define this to disable the Entry Reusage System.
* All code except the typedef of ERInterface will be disabled. * All code except the typedef of ERInterface will be disabled.
* To allow a smooth transition, * To allow a smooth transition,
* @public
*/ */
//#define DISABLE_ERS //#define DISABLE_ERS
@ -67,8 +65,6 @@
* This should NEVER be set to zero or less. * This should NEVER be set to zero or less.
* If greater than one, some memory can be wasted. This should never be needed * If greater than one, some memory can be wasted. This should never be needed
* but is here just in case some aligment issues arise. * but is here just in case some aligment issues arise.
* @public
* @see #ers_new(uint32)
*/ */
#ifndef ERS_ALIGNED #ifndef ERS_ALIGNED
# define ERS_ALIGNED 1 # define ERS_ALIGNED 1
@ -80,8 +76,6 @@
* @param free Free an entry allocated from this manager * @param free Free an entry allocated from this manager
* @param entry_size Return the size of the entries of this manager * @param entry_size Return the size of the entries of this manager
* @param destroy Destroy this instance of the manager * @param destroy Destroy this instance of the manager
* @public
* @see #ers_new(uint32)
*/ */
typedef struct eri { typedef struct eri {
@ -90,9 +84,6 @@ typedef struct eri {
* If there are reusable entries available, it reuses one instead. * If there are reusable entries available, it reuses one instead.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @return An entry * @return An entry
* @protected
* @see #ERInterface
* @see ERInterface#free(ERInterface,void *)
*/ */
void *(*alloc)(struct eri *self); void *(*alloc)(struct eri *self);
@ -102,9 +93,6 @@ typedef struct eri {
* Freeing such an entry can lead to unexpected behaviour. * Freeing such an entry can lead to unexpected behaviour.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @param entry Entry to be freed * @param entry Entry to be freed
* @protected
* @see #ERInterface
* @see ERInterface#alloc(ERInterface)
*/ */
void (*free)(struct eri *self, void *entry); void (*free)(struct eri *self, void *entry);
@ -112,8 +100,6 @@ typedef struct eri {
* Return the size of the entries allocated from this manager. * Return the size of the entries allocated from this manager.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @return Size of the entries of this manager in bytes * @return Size of the entries of this manager in bytes
* @protected
* @see #ERInterface
*/ */
uint32 (*entry_size)(struct eri *self); uint32 (*entry_size)(struct eri *self);
@ -123,13 +109,10 @@ typedef struct eri {
* When destroying the manager a warning is shown if the manager has * When destroying the manager a warning is shown if the manager has
* missing/extra entries. * missing/extra entries.
* @param self Interface of the entry manager * @param self Interface of the entry manager
* @protected
* @see #ERInterface
* @see #ers_new(uint32)
*/ */
void (*destroy)(struct eri *self); void (*destroy)(struct eri *self);
} *ERInterface; } *ERS;
#ifdef DISABLE_ERS #ifdef DISABLE_ERS
// Use memory manager to allocate/free and disable other interface functions // Use memory manager to allocate/free and disable other interface functions
@ -158,13 +141,8 @@ typedef struct eri {
* ERS_ALIGNED that is greater or equal to size is what's actually used. * ERS_ALIGNED that is greater or equal to size is what's actually used.
* @param The requested size of the entry in bytes * @param The requested size of the entry in bytes
* @return Interface of the object * @return Interface of the object
* @public
* @see #ERS_ALIGNED
* @see #ERInterface
* @see ERInterface#destroy(ERInterface)
* @see common\ers.c#ers_new(uint32)
*/ */
ERInterface ers_new(uint32 size); ERS ers_new(size_t size);
/** /**
* Print a report about the current state of the Entry Reusage System. * Print a report about the current state of the Entry Reusage System.
@ -172,8 +150,6 @@ ERInterface ers_new(uint32 size);
* The number of entries are checked and a warning is shown if extra reusable * The number of entries are checked and a warning is shown if extra reusable
* entries are found. * entries are found.
* The extra entries are included in the count of reusable entries. * The extra entries are included in the count of reusable entries.
* @public
* @see common\ers.c#ers_report(void)
*/ */
void ers_report(void); void ers_report(void);
@ -184,8 +160,6 @@ void ers_report(void);
* The use of this is NOT recommended. * The use of this is NOT recommended.
* It should only be used in extreme situations to make shure all the memory * It should only be used in extreme situations to make shure all the memory
* allocated by this system is released. * allocated by this system is released.
* @public
* @see common\ers.c#ers_force_destroy_all(void)
*/ */
void ers_force_destroy_all(void); void ers_force_destroy_all(void);
#endif /* DISABLE_ERS / not DISABLE_ERS */ #endif /* DISABLE_ERS / not DISABLE_ERS */

View File

@ -230,7 +230,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
{ // from here, we will skip the '\033[' { // from here, we will skip the '\033['
// we break at the first unprocessible position // we break at the first unprocessible position
// assuming regular text is starting there // assuming regular text is starting there
uchar numbers[16], numpoint=0; uint8 numbers[16], numpoint=0;
CONSOLE_SCREEN_BUFFER_INFO info; CONSOLE_SCREEN_BUFFER_INFO info;
// initialize // initialize
@ -266,7 +266,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
} }
else if( *q == 'm' ) else if( *q == 'm' )
{ // \033[#;...;#m - Set Graphics Rendition (SGR) { // \033[#;...;#m - Set Graphics Rendition (SGR)
uint i; uint8 i;
for(i=0; i<= numpoint; ++i) for(i=0; i<= numpoint; ++i)
{ {
if( 0x00 == (0xF0 & numbers[i]) ) if( 0x00 == (0xF0 & numbers[i]) )
@ -314,7 +314,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
} }
else if( 0x30 == (0xF0 & numbers[i]) ) else if( 0x30 == (0xF0 & numbers[i]) )
{ // foreground { // foreground
uint num = numbers[i]&0x0F; uint8 num = numbers[i]&0x0F;
if(num==9) info.wAttributes |= FOREGROUND_INTENSITY; if(num==9) info.wAttributes |= FOREGROUND_INTENSITY;
if(num>7) num=7; // set white for 37, 38 and 39 if(num>7) num=7; // set white for 37, 38 and 39
info.wAttributes &= ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); info.wAttributes &= ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
@ -327,7 +327,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
} }
else if( 0x40 == (0xF0 & numbers[i]) ) else if( 0x40 == (0xF0 & numbers[i]) )
{ // background { // background
uint num = numbers[i]&0x0F; uint8 num = numbers[i]&0x0F;
if(num==9) info.wAttributes |= BACKGROUND_INTENSITY; if(num==9) info.wAttributes |= BACKGROUND_INTENSITY;
if(num>7) num=7; // set white for 47, 48 and 49 if(num>7) num=7; // set white for 47, 48 and 49
info.wAttributes &= ~(BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE); info.wAttributes &= ~(BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);
@ -347,7 +347,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
// \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged. // \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged.
// \033[1J - Clears the screen from start to cursor. The cursor position is unchanged. // \033[1J - Clears the screen from start to cursor. The cursor position is unchanged.
// \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1). // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1).
uint num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F);
int cnt; int cnt;
COORD origin = {0,0}; COORD origin = {0,0};
if(num==1) if(num==1)
@ -373,7 +373,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
// \033[1K - Clears all characters from start of line to the cursor position. // \033[1K - Clears all characters from start of line to the cursor position.
// \033[2K - Clears all characters of the whole line. // \033[2K - Clears all characters of the whole line.
uint num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F);
COORD origin = {0,info.dwCursorPosition.Y}; COORD origin = {0,info.dwCursorPosition.Y};
SHORT cnt; SHORT cnt;
if(num==1) if(num==1)

View File

@ -8,10 +8,9 @@
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
#include "../common/cbasetypes.h" #include "../common/mmo.h"
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/nullpo.h" #include "../common/nullpo.h"
#include "../common/mmo.h"
#include "../common/core.h" #include "../common/core.h"
#include "../common/showmsg.h" #include "../common/showmsg.h"
#include "../common/malloc.h" #include "../common/malloc.h"

View File

@ -4480,7 +4480,7 @@ int battle_config_read(const char *cfgName)
} }
void do_init_battle(void) { void do_init_battle(void) {
delay_damage_ers = ers_new((uint32)sizeof(struct delay_damage)); delay_damage_ers = ers_new(sizeof(struct delay_damage));
} }
void do_final_battle(void) { void do_final_battle(void) {

View File

@ -3242,7 +3242,7 @@ int clif_changeoption(struct block_list* bl)
WBUFW(buf,6) = sc->opt1; WBUFW(buf,6) = sc->opt1;
WBUFW(buf,8) = sc->opt2; WBUFW(buf,8) = sc->opt2;
WBUFL(buf,10) = sc->option; WBUFL(buf,10) = sc->option;
WBUFB(buf,14) = 0; // ?? WBUFB(buf,14) = 0; // PK???
if(disguised(bl)) { if(disguised(bl)) {
clif_send(buf,packet_len_table[0x229],bl,AREA_WOS); clif_send(buf,packet_len_table[0x229],bl,AREA_WOS);
WBUFL(buf,2) = -bl->id; WBUFL(buf,2) = -bl->id;

View File

@ -206,7 +206,7 @@ void do_init_guild(void)
castle_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int)); castle_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int));
guild_expcache_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); guild_expcache_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int));
guild_infoevent_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); guild_infoevent_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int));
expcache_ers = ers_new((uint32)sizeof(struct guild_expcache)); expcache_ers = ers_new(sizeof(struct guild_expcache));
guild_castleinfoevent_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); guild_castleinfoevent_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int));
guild_read_castledb(); guild_read_castledb();

View File

@ -4195,8 +4195,8 @@ int do_init_mob(void)
malloc_set(mob_db_data,0,sizeof(mob_db_data)); //Clear the array malloc_set(mob_db_data,0,sizeof(mob_db_data)); //Clear the array
mob_db_data[0] = aCalloc(1, sizeof (struct mob_data)); //This mob is used for random spawns mob_db_data[0] = aCalloc(1, sizeof (struct mob_data)); //This mob is used for random spawns
mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob
item_drop_ers = ers_new((uint32)sizeof(struct item_drop)); item_drop_ers = ers_new(sizeof(struct item_drop));
item_drop_list_ers = ers_new((uint32)sizeof(struct item_drop_list)); item_drop_list_ers = ers_new(sizeof(struct item_drop_list));
#ifndef TXT_ONLY #ifndef TXT_ONLY
if(db_use_sqldbs) if(db_use_sqldbs)

View File

@ -3013,7 +3013,7 @@ int do_init_npc(void)
npcname_db = db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_BASE,NAME_LENGTH); npcname_db = db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_BASE,NAME_LENGTH);
malloc_set(&ev_tm_b, -1, sizeof(ev_tm_b)); malloc_set(&ev_tm_b, -1, sizeof(ev_tm_b));
timer_event_ers = ers_new((uint32)sizeof(struct timer_event_data)); timer_event_ers = ers_new(sizeof(struct timer_event_data));
for (nsl = npc_src_first; nsl; nsl = nsl->next) { for (nsl = npc_src_first; nsl; nsl = nsl->next) {
npc_parsesrcfile(nsl->name); npc_parsesrcfile(nsl->name);

View File

@ -1371,8 +1371,8 @@ int do_init_pet(void)
malloc_set(pet_db,0,sizeof(pet_db)); malloc_set(pet_db,0,sizeof(pet_db));
read_petdb(); read_petdb();
item_drop_ers = ers_new((uint32)sizeof(struct item_drop)); item_drop_ers = ers_new(sizeof(struct item_drop));
item_drop_list_ers = ers_new((uint32)sizeof(struct item_drop_list)); item_drop_list_ers = ers_new(sizeof(struct item_drop_list));
add_timer_func_list(pet_hungry,"pet_hungry"); add_timer_func_list(pet_hungry,"pet_hungry");
add_timer_func_list(pet_ai_hard,"pet_ai_hard"); add_timer_func_list(pet_ai_hard,"pet_ai_hard");

View File

@ -11647,8 +11647,8 @@ int do_init_skill (void)
skill_readdb(); skill_readdb();
skill_dance_switch_sub(NULL, NULL, 2); //Initialize Song/Dance overlap switch code. skill_dance_switch_sub(NULL, NULL, 2); //Initialize Song/Dance overlap switch code.
skill_unit_ers = ers_new((uint32)sizeof(struct skill_unit_group)); skill_unit_ers = ers_new(sizeof(struct skill_unit_group));
skill_timer_ers = ers_new((uint32)sizeof(struct skill_timerskill)); skill_timer_ers = ers_new(sizeof(struct skill_timerskill));
if (battle_config.skill_sp_override_grffile) if (battle_config.skill_sp_override_grffile)
skill_read_skillspamount(); skill_read_skillspamount();

View File

@ -2,14 +2,14 @@ all sql: char-converter login-converter
char-converter: char-converter.o ../common/obj/minicore.o \ char-converter: char-converter.o ../common/obj/minicore.o \
../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \
../common/obj/mapindex.o ../common/obj/ers.o \ ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/utils.o \
../char/char.o ../char/int_pet.o ../char/int_storage.o ../char/inter.o \ ../char/char.o ../char/int_pet.o ../char/int_storage.o ../char/inter.o \
../char/int_party.o ../char/int_guild.o \ ../char/int_party.o ../char/int_guild.o \
../char_sql/char.o ../char_sql/int_pet.o ../char_sql/int_storage.o \ ../char_sql/char.o ../char_sql/int_pet.o ../char_sql/int_storage.o \
../char_sql/inter.o ../char_sql/int_party.o ../char_sql/int_guild.o ../char_sql/inter.o ../char_sql/int_party.o ../char_sql/int_guild.o
$(CC) -o ../../tools/$@ $^ $(LIB_S) $(CC) -o ../../tools/$@ $^ $(LIB_S)
login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o ../common/obj/utils.o
$(CC) -o ../../tools/$@ $^ $(LIB_S) $(CC) -o ../../tools/$@ $^ $(LIB_S)
clean: clean:

View File

@ -5,9 +5,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../common/mmo.h"
#include "../common/core.h" #include "../common/core.h"
#include "../common/strlib.h" #include "../common/strlib.h"
#include "../common/mmo.h"
#include "../common/showmsg.h" #include "../common/showmsg.h"
#include "../common/mapindex.h" #include "../common/mapindex.h"

View File

@ -4,12 +4,16 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "cbasetypes.h"
#ifdef __WIN32
#include <my_global.h> #include <my_global.h>
#include <my_sys.h>
#endif
#include <mysql.h> #include <mysql.h>
#include "../common/mmo.h"
#include "../common/core.h" #include "../common/core.h"
#include "../common/db.h" #include "../common/db.h"
#include "../common/mmo.h"
struct auth_dat_ { struct auth_dat_ {
int account_id, sex; int account_id, sex;