فهرست منبع

- Hercules merge : (with improvment)
-- 3b6289f : missing guild association for sd. (yes again)
-- c653a70 : Documentation for malloc.c
-- 8ec2352 : Iterator not being destroy when no guild.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17263 54d463be-8e91-2dee-dedb-b68131a5f0ec

glighta 12 سال پیش
والد
کامیت
906083c029
5فایلهای تغییر یافته به همراه52 افزوده شده و 49 حذف شده
  1. 46 46
      src/common/malloc.c
  2. 2 1
      src/map/atcommand.c
  3. 1 1
      src/map/clif.c
  4. 2 0
      src/map/guild.c
  5. 1 1
      src/map/skill.c

+ 46 - 46
src/common/malloc.c

@@ -129,49 +129,49 @@ void aFree_(void *p, const char *file, int line, const char *func)
 /* USE_MEMMGR */
 
 /*
- * メモリマネージャ
- *     malloc , free の処理を効率的に出来るようにしたもの。
- *     複雑な処理を行っているので、若干重くなるかもしれません。
+ * Memory manager
+ *     able to handle malloc and free efficiently
+ *     Since the complex processing, I might be slightly heavier.
  *
- * データ構造など(説明下手ですいません^^; )
- *     ・メモリを複数の「ブロック」に分けて、さらにブロックを複数の「ユニット」
- *       に分けています。ユニットのサイズは、1ブロックの容量を複数個に均等配分
- *       したものです。たとえば、1ユニット32KBの場合、ブロック1つは32Byteのユ
- *       ニットが、1024個集まって出来ていたり、64Byteのユニットが 512個集まって
- *       出来ていたりします。(padding,unit_head を除く)
+ * (I'm sorry for the poor description ^ ^;) such as data structures
+ *		Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further
+ *      I have to divide. Size of the unit, a plurality of distribution equal to the capacity of one block
+ *      That's what you have. For example, if one unit of 32KB, one block 1 Yu 32Byte
+ *      Knit, or are able to gather 1024, gathered 512 units 64Byte
+ *      I can be or have. (Excluding padding, the unit_head)
  *
- *     ・ブロック同士はリンクリスト(block_prev,block_next) でつながり、同じサイ
- *       ズを持つブロック同士もリンクリスト(hash_prev,hash_nect) でつな
- *       がっています。それにより、不要となったメモリの再利用が効率的に行えます。
+ *     Lead-linked list (block_prev, block_next) in each other is the same size block
+ *       Linked list (hash_prev, hash_nect) even among such one in the block with the figure
+ *       I like to have. Thus, reuse of memory no longer needed can be performed efficiently.
  */
 
-/* ブロックのアライメント */
+/* Alignment of the block */
 #define BLOCK_ALIGNMENT1	16
 #define BLOCK_ALIGNMENT2	64
 
-/* ブロックに入るデータ量 */
+/* Amount of data entering a block */
 #define BLOCK_DATA_COUNT1	128
 #define BLOCK_DATA_COUNT2	608
 
-/* ブロックの大きさ: 16*128 + 64*576 = 40KB */
+/* The size of the block: 16*128 + 64*576 = 40KB */
 #define BLOCK_DATA_SIZE1	( BLOCK_ALIGNMENT1 * BLOCK_DATA_COUNT1 )
 #define BLOCK_DATA_SIZE2	( BLOCK_ALIGNMENT2 * BLOCK_DATA_COUNT2 )
 #define BLOCK_DATA_SIZE		( BLOCK_DATA_SIZE1 + BLOCK_DATA_SIZE2 )
 
-/* 一度に確保するブロックの数。 */
+/* The number of blocks to be allocated at a time. */
 #define BLOCK_ALLOC		104
 
-/* ブロック */
+/* block */
 struct block {
-	struct block* block_next;		/* 次に確保した領域 */
-	struct block* unfill_prev;		/* 次の埋まっていない領域 */
-	struct block* unfill_next;		/* 次の埋まっていない領域 */
-	unsigned short unit_size;		/* ユニットの大きさ */
-	unsigned short unit_hash;		/* ユニットのハッシュ */
-	unsigned short unit_count;		/* ユニットの個数 */
-	unsigned short unit_used;		/* 使用ユニット数 */
-	unsigned short unit_unfill;		/* 未使用ユニットの場所 */
-	unsigned short unit_maxused;	/* 使用ユニットの最大値 */
+	struct block* block_next;		/* Then the allocated area */
+	struct block* unfill_prev;		/* The previous area not filled */
+	struct block* unfill_next;		/* The next area not filled */
+	unsigned short unit_size;		/* The size of the unit */
+	unsigned short unit_hash;		/* The hash of the unit */
+	unsigned short unit_count;		/* The number of units */
+	unsigned short unit_used;		/* The number of used units */
+	unsigned short unit_unfill;		/* The number of unused units */
+	unsigned short unit_maxused;	/* The maximum value of units used */
 	char   data[ BLOCK_DATA_SIZE ];
 };
 
@@ -186,7 +186,7 @@ struct unit_head {
 static struct block* hash_unfill[BLOCK_DATA_COUNT1 + BLOCK_DATA_COUNT2 + 1];
 static struct block* block_first, *block_last, block_head;
 
-/* メモリを使い回せない領域用のデータ */
+/* Data for areas that do not use the memory be turned */
 struct unit_head_large {
 	size_t                  size;
 	struct unit_head_large* prev;
@@ -211,7 +211,7 @@ static unsigned short size2hash( size_t size )
 		return (unsigned short)(size - BLOCK_DATA_SIZE1 + BLOCK_ALIGNMENT2 - 1) / BLOCK_ALIGNMENT2
 				+ BLOCK_DATA_COUNT1;
 	} else {
-		return 0xffff;	// ブロック長を超える場合は hash にしない
+		return 0xffff;	// If it exceeds the block length hash I do not
 	}
 }
 
@@ -240,8 +240,8 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 	}
 	memmgr_usage_bytes += size;
 
-	/* ブロック長を超える領域の確保には、malloc() を用いる */
-	/* その際、unit_head.block に NULL を代入して区別する */
+	/* To ensure the area that exceeds the length of the block, using malloc () to */
+	/* At that time, the distinction by assigning NULL to unit_head.block */
 	if(hash2size(size_hash) > BLOCK_DATA_SIZE - sizeof(struct unit_head)) {
 		struct unit_head_large* p = (struct unit_head_large*)MALLOC(sizeof(struct unit_head_large)+size,file,line,func);
 		if(p != NULL) {
@@ -266,7 +266,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 		}
 	}
 
-	/* 同一サイズのブロックが確保されていない時、新たに確保する */
+	/* When a block of the same size is not ensured, to ensure a new */
 	if(hash_unfill[size_hash]) {
 		block = hash_unfill[size_hash];
 	} else {
@@ -274,7 +274,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 	}
 
 	if( block->unit_unfill == 0xFFFF ) {
-		// free済み領域が残っていない
+		// there are no more free space that
 		memmgr_assert(block->unit_used <  block->unit_count);
 		memmgr_assert(block->unit_used == block->unit_maxused);
 		head = block2unit(block, block->unit_maxused);
@@ -287,7 +287,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 	}
 
 	if( block->unit_unfill == 0xFFFF && block->unit_maxused >= block->unit_count) {
-		// ユニットを使い果たしたので、unfillリストから削除
+		// Since I ran out of the unit, removed from the list unfill
 		if( block->unfill_prev == &block_head) {
 			hash_unfill[ size_hash ] = block->unfill_next;
 		} else {
@@ -348,10 +348,10 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c
 		old_size = ((struct unit_head_large *)((char *)memblock - sizeof(struct unit_head_large) + sizeof(long)))->size;
 	}
 	if(old_size > size) {
-		// サイズ縮小 -> そのまま返す(手抜き)
+		// Size reduction - return> as it is (negligence)
 		return memblock;
 	}  else {
-		// サイズ拡大
+		// Size Large
 		void *p = _mmalloc(size,file,line,func);
 		if(p != NULL) {
 			memcpy(p,memblock,old_size);
@@ -382,7 +382,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 
 	head = (struct unit_head *)((char *)ptr - sizeof(struct unit_head) + sizeof(long));
 	if(head->size == 0) {
-		/* malloc() で直に確保された領域 */
+		/* area that is directly secured by malloc () */
 		struct unit_head_large *head_large = (struct unit_head_large *)((char *)ptr - sizeof(struct unit_head_large) + sizeof(long));
 		if(
 			*(long*)((char*)head_large + sizeof(struct unit_head_large) - sizeof(long) + head_large->size)
@@ -407,7 +407,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 			FREE(head_large,file,line,func);
 		}
 	} else {
-		/* ユニット解放 */
+		/* Release unit */
 		struct block *block = head->block;
 		if( (char*)head - (char*)block > sizeof(struct block) ) {
 			ShowError("Memory manager: args of aFree 0x%p is invalid pointer %s line %d\n", ptr, file, line);
@@ -425,11 +425,11 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 #endif
 			memmgr_assert( block->unit_used > 0 );
 			if(--block->unit_used == 0) {
-				/* ブロックの解放 */
+				/* Release of the block */
 				block_free(block);
 			} else {
 				if( block->unfill_prev == NULL) {
-					// unfill リストに追加
+					// add to unfill list
 					if( hash_unfill[ block->unit_hash ] ) {
 						hash_unfill[ block->unit_hash ]->unfill_prev = block;
 					}
@@ -444,17 +444,17 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 	}
 }
 
-/* ブロックを確保する */
+/* Allocating blocks */
 static struct block* block_malloc(unsigned short hash)
 {
 	int i;
 	struct block *p;
 	if(hash_unfill[0] != NULL) {
-		/* ブロック用の領域は確保済み */
+		/* Space for the block has already been secured */
 		p = hash_unfill[0];
 		hash_unfill[0] = hash_unfill[0]->unfill_next;
 	} else {
-		/* ブロック用の領域を新たに確保する */
+		/* Newly allocated space for the block */
 		p = (struct block*)MALLOC(sizeof(struct block) * (BLOCK_ALLOC), __FILE__, __LINE__, __func__ );
 		if(p == NULL) {
 			ShowFatalError("Memory manager::block_alloc failed.\n");
@@ -462,17 +462,17 @@ static struct block* block_malloc(unsigned short hash)
 		}
 
 		if(block_first == NULL) {
-			/* 初回確保 */
+			/* First ensure */
 			block_first = p;
 		} else {
 			block_last->block_next = p;
 		}
 		block_last = &p[BLOCK_ALLOC - 1];
 		block_last->block_next = NULL;
-		/* ブロックを連結させる */
+		/* Linking the block */
 		for(i=0;i<BLOCK_ALLOC;i++) {
 			if(i != 0) {
-				// p[0] はこれから使うのでリンクには加えない
+				// I do not add the link p [0], so we will use
 				p[i].unfill_next = hash_unfill[0];
 				hash_unfill[0]   = &p[i];
 				p[i].unfill_prev = NULL;
@@ -484,7 +484,7 @@ static struct block* block_malloc(unsigned short hash)
 		}
 	}
 
-	// unfill に追加
+	// Add to unfill
 	memmgr_assert(hash_unfill[ hash ] == NULL);
 	hash_unfill[ hash ] = p;
 	p->unfill_prev  = &block_head;

+ 2 - 1
src/map/atcommand.c

@@ -8928,7 +8928,7 @@ ACMD_FUNC(channel)
 				WFIFOSET(fd, msg_len + 12);
 			}
 		} else {
-			DBIterator *iter = db_iterator(channel_db);
+			DBIterator *iter;
 			bool show_all = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ? true : false;
 			clif_displaymessage(fd, msg_txt(sd,1410)); // ---- Public Channels ----
 			if( raChSys.local ) {
@@ -8941,6 +8941,7 @@ ACMD_FUNC(channel)
 				sprintf(atcmd_output, msg_txt(sd,1409), raChSys.ally_name, db_size(((struct raChSysCh *)g->channel)->users));// - #%s ( %d users )
 				clif_displaymessage(fd, atcmd_output);
 			}
+			iter = db_iterator(channel_db);
 			for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
 				if( show_all || channel->type == raChSys_PUBLIC ) {
 					sprintf(atcmd_output, msg_txt(sd,1409), channel->name, db_size(channel->users));// - #%s (%d users)

+ 1 - 1
src/map/clif.c

@@ -5370,7 +5370,7 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val
 	if(flag && battle_config.display_status_timers && sd) {
 		if (tick <= 0)
 			tick = 9999; // this is indeed what official servers do
-		
+
 		WBUFL(buf,9)=tick;/* at this stage remain and total are the same value I believe */
 		WBUFL(buf,13)=tick;
 		WBUFL(buf,17) = val1;

+ 2 - 0
src/map/guild.c

@@ -551,6 +551,7 @@ int guild_recv_info(struct guild *sg)
 				guild_block_skill(sd, 300000);
 
 			//Also set the guild master flag.
+			sd->guild = g;
 			sd->state.gmaster_flag = g;
 			clif_charnameupdate(sd); // [LuzZza]
 			clif_guild_masterormember(sd);
@@ -584,6 +585,7 @@ int guild_recv_info(struct guild *sg)
 		sd = g->member[i].sd;
 		if( sd==NULL )
 			continue;
+		sd->guild = g;
 
 		if (before.guild_lv != g->guild_lv || bm != m ||
 			before.max_member != g->max_member) {

+ 1 - 1
src/map/skill.c

@@ -16808,7 +16808,7 @@ static void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id)
 #ifndef RENEWAL
 			if(bl->type == BL_PC){// update current display.
 				clif_updatestatus(((TBL_PC *)bl),SP_MATK1);
-			    clif_updatestatus(((TBL_PC *)bl),SP_MATK2);
+				clif_updatestatus(((TBL_PC *)bl),SP_MATK2);
 			}
 #endif
 		}