Browse Source

* Hunted down the simpler 64bit pointer truncations.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13380 54d463be-8e91-2dee-dedb-b68131a5f0ec
FlavioJS 16 năm trước cách đây
mục cha
commit
72542d65cc

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2008/11/22
+	* Hunted down the simpler 64bit pointer truncations. [FlavioJS]
 2008/11/18
 	* Rev. 13375 Autotrade characters will no longer get caught by Urgent Recall. (bugreport:2447) [L0ne_W0lf]
 2008/11/11

+ 1 - 1
src/common/malloc.c

@@ -428,7 +428,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 					hash_unfill[ block->unit_hash ] = block;
 				}
 				head->size     = block->unit_unfill;
-				block->unit_unfill = (unsigned short)(((unsigned long)head - (unsigned long)block->data) / block->unit_size);
+				block->unit_unfill = (unsigned short)(((uintptr)head - (uintptr)block->data) / block->unit_size);
 			}
 		}
 	}

+ 1 - 1
src/common/sql.c

@@ -212,7 +212,7 @@ static int Sql_P_Keepalive(Sql* self)
 	// establish keepalive
 	ping_interval = timeout - 30; // 30-second reserve
 	//add_timer_func_list(Sql_P_KeepaliveTimer, "Sql_P_KeepaliveTimer");
-	return add_timer_interval(gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (int)self, ping_interval*1000);
+	return add_timer_interval(gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr)self, ping_interval*1000);
 }
 
 

+ 6 - 6
src/common/timer.c

@@ -63,9 +63,9 @@ int add_timer_func_list(TimerFunc func, char* name)
 		for( tfl=tfl_root; tfl != NULL; tfl=tfl->next )
 		{// check suspicious cases
 			if( func == tfl->func )
-				ShowWarning("add_timer_func_list: duplicating function %08x(%s) as %s.\n",(int)tfl->func,tfl->name,name);
+				ShowWarning("add_timer_func_list: duplicating function %p(%s) as %s.\n",tfl->func,tfl->name,name);
 			else if( strcmp(name,tfl->name) == 0 )
-				ShowWarning("add_timer_func_list: function %08X has the same name as %08X(%s)\n",(int)func,(int)tfl->func,tfl->name);
+				ShowWarning("add_timer_func_list: function %p has the same name as %p(%s)\n",func,tfl->func,tfl->name);
 		}
 		CREATE(tfl,struct timer_func_list,1);
 		tfl->next = tfl_root;
@@ -256,7 +256,7 @@ int add_timer_interval(unsigned int tick, TimerFunc func, int id, intptr data, i
 
 	if( interval < 1 )
 	{
-		ShowError("add_timer_interval: invalid interval (tick=%u %08x[%s] id=%d data=%d diff_tick=%d)\n", tick, (int)func, search_timer_func_list(func), id, data, DIFF_TICK(tick, gettick()));
+		ShowError("add_timer_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, gettick()));
 		return INVALID_TIMER;
 	}
 	
@@ -285,12 +285,12 @@ int delete_timer(int tid, TimerFunc func)
 {
 	if( tid < 0 || tid >= timer_data_num )
 	{
-		ShowError("delete_timer error : no such timer %d (%08x(%s))\n", tid, (int)func, search_timer_func_list(func));
+		ShowError("delete_timer error : no such timer %d (%p(%s))\n", tid, func, search_timer_func_list(func));
 		return -1;
 	}
 	if( timer_data[tid].func != func )
 	{
-		ShowError("delete_timer error : function mismatch %08x(%s) != %08x(%s)\n", (int)timer_data[tid].func, search_timer_func_list(timer_data[tid].func), (int)func, search_timer_func_list(func));
+		ShowError("delete_timer error : function mismatch %p(%s) != %p(%s)\n", timer_data[tid].func, search_timer_func_list(timer_data[tid].func), func, search_timer_func_list(func));
 		return -2;
 	}
 
@@ -324,7 +324,7 @@ int settick_timer(int tid, unsigned int tick)
 	{// skip timers with the same tick
 		if( old_tick != timer_data[timer_heap[old_pos]].tick )
 		{
-			ShowError("settick_timer: no such timer %d (%08x(%s))\n", tid, (int)timer_data[tid].func, search_timer_func_list(timer_data[tid].func));
+			ShowError("settick_timer: no such timer %d (%p(%s))\n", tid, timer_data[tid].func, search_timer_func_list(timer_data[tid].func));
 			return -1;
 		}
 		++old_pos;

+ 1 - 1
src/login/account_txt.c

@@ -183,7 +183,7 @@ static bool account_db_txt_init(AccountDB* self)
 
 	// initialize data saving timer
 	add_timer_func_list(mmo_auth_sync_timer, "mmo_auth_sync_timer");
-	db->save_timer = add_timer_interval(gettick() + AUTH_SAVING_INTERVAL, mmo_auth_sync_timer, 0, (int)db, AUTH_SAVING_INTERVAL);
+	db->save_timer = add_timer_interval(gettick() + AUTH_SAVING_INTERVAL, mmo_auth_sync_timer, 0, (intptr)db, AUTH_SAVING_INTERVAL);
 
 	return true;
 }

+ 1 - 1
src/map/atcommand.c

@@ -8739,7 +8739,7 @@ int atcommand_commands(const int fd, struct map_session_data* sd, const char* co
 		slen = (unsigned int)strlen(atcommand_info[i].command);
 
 		// flush the text buffer if this command won't fit into it
-		if( ((CHATBOX_SIZE-1+(int)line_buff)-(int)cur) < (int)slen )
+		if( slen + cur - line_buff >= CHATBOX_SIZE )
 		{
 			clif_displaymessage(fd,line_buff);
 			cur = line_buff;

+ 1 - 1
src/map/battle.c

@@ -206,7 +206,7 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src,
 	dat->distance = distance_bl(src, target)+10; //Attack should connect regardless unless you teleported.
 	if (src->type != BL_PC && amotion > 1000)
 		amotion = 1000; //Aegis places a damage-delay cap of 1 sec to non player attacks. [Skotlex]
-	add_timer(tick+amotion, battle_delay_damage_sub, src->id, (int)dat);
+	add_timer(tick+amotion, battle_delay_damage_sub, src->id, (intptr)dat);
 	
 	return 0;
 }

+ 2 - 2
src/map/clif.c

@@ -633,7 +633,7 @@ int clif_clearunit_area(struct block_list* bl, uint8 type)
 
 static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr data)
 {
-	struct block_list *bl = (struct block_list *)id;
+	struct block_list *bl = (struct block_list *)data;
 	clif_clearunit_area(bl, 0);
 	aFree(bl);
 	return 0;
@@ -644,7 +644,7 @@ int clif_clearunit_delayed(struct block_list* bl, unsigned int tick)
 	struct block_list *tbl;
 	tbl = (struct block_list*)aMalloc(sizeof (struct block_list));
 	memcpy (tbl, bl, sizeof (struct block_list));
-	add_timer(tick, clif_clearunit_delayed_sub, (int)tbl, 0);
+	add_timer(tick, clif_clearunit_delayed_sub, 0, (intptr)tbl);
 	return 0;
 }
 

+ 1 - 1
src/map/guild.c

@@ -1874,7 +1874,7 @@ int guild_castlealldataload(int len,struct guild_castle *gc)
 		}
 
 		// update mapserver castle data with new info
-		memcpy(&c->guild_id, &gc->guild_id, sizeof(struct guild_castle) - ((int)&c->guild_id - (int)c));
+		memcpy(&c->guild_id, &gc->guild_id, sizeof(struct guild_castle) - ((uintptr)&c->guild_id - (uintptr)c));
 
 		if( c->guild_id )
 		{

+ 3 - 3
src/map/mob.c

@@ -1632,7 +1632,7 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr data)
 {
 	struct item_drop_list *list;
 	struct item_drop *ditem, *ditem_prev;
-	list=(struct item_drop_list *)id;
+	list=(struct item_drop_list *)data;
 	ditem = list->item;
 	while (ditem) {
 		map_addflooritem(&ditem->item_data,ditem->item_data.amount,
@@ -2218,7 +2218,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 				mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, 0);
 		}
 		if (dlist->item) //There are drop items.
-			add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, (int)dlist, 0);
+			add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr)dlist);
 		else //No drops
 			ers_free(item_drop_list_ers, dlist);
 	} else if (md->lootitem && md->lootitem_count) {	//Loot MUST drop!
@@ -2232,7 +2232,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		dlist->item = NULL;
 		for(i = 0; i < md->lootitem_count; i++)
 			mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, 0);
-		add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, (int)dlist, 0);
+		add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr)dlist);
 	}
 
 	if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai)

+ 4 - 4
src/map/npc.c

@@ -434,9 +434,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr data)
 			- nd->u.scr.timer_event[ ted->next-1 ].timer;
 		ted->time+=next;
 		if (sd)
-			sd->npc_timer_id = add_timer(tick+next,npc_timerevent,id,(int)ted);
+			sd->npc_timer_id = add_timer(tick+next,npc_timerevent,id,(intptr)ted);
 		else
-			nd->u.scr.timerid = add_timer(tick+next,npc_timerevent,id,(int)ted);
+			nd->u.scr.timerid = add_timer(tick+next,npc_timerevent,id,(intptr)ted);
 	} else {
 		if (sd)
 			sd->npc_timer_id = -1;
@@ -500,9 +500,9 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
 	next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer;
 	ted->time = nd->u.scr.timer_event[j].timer;
 	if (sd)
-		sd->npc_timer_id = add_timer(gettick()+next,npc_timerevent,nd->bl.id,(int)ted);
+		sd->npc_timer_id = add_timer(gettick()+next,npc_timerevent,nd->bl.id,(intptr)ted);
 	else
-		nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,(int)ted);
+		nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,(intptr)ted);
 	return 0;
 }
 /*==========================================

+ 1 - 1
src/map/pc.c

@@ -6393,7 +6393,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name)
 	if( i == MAX_EVENTTIMER )
 		return 0;
 
-	sd->eventtimer[i] = add_timer(gettick()+tick, pc_eventtimer, sd->bl.id, (int)aStrdup(name));
+	sd->eventtimer[i] = add_timer(gettick()+tick, pc_eventtimer, sd->bl.id, (intptr)aStrdup(name));
 	sd->eventcount++;
 
 	return 1;

+ 2 - 2
src/map/pet.c

@@ -955,7 +955,7 @@ static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr data)
 {
 	struct item_drop_list *list;
 	struct item_drop *ditem, *ditem_prev;
-	list=(struct item_drop_list *)id;
+	list=(struct item_drop_list *)data;
 	ditem = list->item;
 	while (ditem) {
 		map_addflooritem(&ditem->item_data,ditem->item_data.amount,
@@ -1012,7 +1012,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
 	pd->ud.canact_tick = gettick()+10000;	//	10*1000ms‚ÌŠÔ�E‚í‚È‚¢
 
 	if (dlist->item)
-		add_timer(gettick()+540,pet_delay_item_drop,(int)dlist,0);
+		add_timer(gettick()+540,pet_delay_item_drop,0,(intptr)dlist);
 	else
 		ers_free(item_drop_list_ers, dlist);
 	return 1;

+ 1 - 1
src/map/script.c

@@ -3150,7 +3150,7 @@ void run_script_main(struct script_state *st)
 		//Delay execution
 		st->sleep.charid = sd?sd->status.char_id:0;
 		st->sleep.timer  = add_timer(gettick()+st->sleep.tick,
-			run_script_timer, st->sleep.charid, (int)st);
+			run_script_timer, st->sleep.charid, (intptr)st);
 		linkdb_insert(&sleep_db, (void*)st->oid, st);
 		//Restore previous script
 		if (sd) {

+ 1 - 1
src/map/unit.c

@@ -803,7 +803,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int
 			//Resume running after can move again [Kevin]
 			if(ud->state.running)
 			{
-				add_timer(ud->canmove_tick, unit_resume_running, bl->id, (int)ud);
+				add_timer(ud->canmove_tick, unit_resume_running, bl->id, (intptr)ud);
 			}
 			else
 			{