Selaa lähdekoodia

Applied patch by xazax to clean up various bits of code across mapserver code. (bugreport:4512)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14438 54d463be-8e91-2dee-dedb-b68131a5f0ec
Paradox924X 14 vuotta sitten
vanhempi
commit
53e81e1369
8 muutettua tiedostoa jossa 10 lisäystä ja 29 poistoa
  1. 2 0
      Changelog-Trunk.txt
  2. 1 3
      src/map/clif.c
  3. 1 2
      src/map/guild.c
  4. 2 2
      src/map/map.c
  5. 1 2
      src/map/npc.c
  6. 2 7
      src/map/script.c
  7. 1 9
      src/map/skill.c
  8. 0 4
      src/map/status.c

+ 2 - 0
Changelog-Trunk.txt

@@ -1,5 +1,7 @@
 Date	Added
 
+2010/11/02
+	* Applied patch by xazax to clean up various bits of code across mapserver code. (bugreport:4512) [Paradox924X]
 2010/11/01
 	* Changed Normal and Cash Food statuses so they do not stack and overwrite the other if the level (val1) is the same or higher. (bugreport:4519) [Paradox924X]
 	* Modified certain atcommands to use 64 bit arithmetic before capping a value to correct boundary logic for overflowing values. [Paradox924X]

+ 1 - 3
src/map/clif.c

@@ -4191,7 +4191,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
 	{	//tsd has lost sight of the bl object.
 		switch(bl->type){
 		case BL_PC:
-			if (((TBL_PC*)bl)->vd.class_ != INVISIBLE_CLASS)
+			if (sd->vd.class_ != INVISIBLE_CLASS)
 				clif_clearunit_single(bl->id,0,tsd->fd);
 			if(sd->chatID){
 				struct chat_data *cd;
@@ -13128,10 +13128,8 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
 {
 	int fail = 0, amount, points;
 	short nameid;
-	struct npc_data *nd;
 	nullpo_retv(sd);
 
-	nd = (struct npc_data *)map_id2bl(sd->npc_shopid);
 	nameid = RFIFOW(fd,2);
 	amount = RFIFOW(fd,4);
 	points = RFIFOL(fd,6); // Not Implemented. Should be 0

+ 1 - 2
src/map/guild.c

@@ -1203,11 +1203,10 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp)
 // Celest
 int guild_getexp(struct map_session_data *sd,int exp)
 {
-	struct guild *g;
 	struct guild_expcache *c;
 	nullpo_ret(sd);
 
-	if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL)
+	if (sd->status.guild_id == 0 || guild_search(sd->status.guild_id) == NULL)
 		return 0;
 
 	c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd);

+ 2 - 2
src/map/map.c

@@ -2673,7 +2673,7 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
  *------------------------------------------*/
 static char *map_init_mapcache(FILE *fp)
 {
-	size_t size = 0, read_size;
+	size_t size = 0;
 	char *buffer;
 
 	// No file open? Return..
@@ -2691,7 +2691,7 @@ static char *map_init_mapcache(FILE *fp)
 	nullpo_ret(buffer);
 
 	// Read file into buffer..
-	if((read_size = fread(buffer, sizeof(char), size, fp)) != size) {
+	if(fread(buffer, sizeof(char), size, fp) != size) {
 		ShowError("map_init_mapcache: Could not read entire mapcache file\n");
 		return NULL;
 	}

+ 1 - 2
src/map/npc.c

@@ -135,12 +135,11 @@ int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd)
  *------------------------------------------*/
 int npc_enable_sub(struct block_list *bl, va_list ap)
 {
-	struct map_session_data *sd;
 	struct npc_data *nd;
 
 	nullpo_ret(bl);
 	nullpo_ret(nd=va_arg(ap,struct npc_data *));
-	if(bl->type == BL_PC && (sd=(struct map_session_data *)bl))
+	if(bl->type == BL_PC)
 	{
 		TBL_PC *sd = (TBL_PC*)bl;
 

+ 2 - 7
src/map/script.c

@@ -7517,7 +7517,6 @@ BUILDIN_FUNC(getmobdrops)
 {
 	int class_ = script_getnum(st,2);
 	int i, j = 0;
-	struct item_data *i_data;
 	struct mob_db *mob;
 
 	if( !mobdb_checkid(class_) )
@@ -7532,7 +7531,7 @@ BUILDIN_FUNC(getmobdrops)
 	{
 		if( mob->dropitem[i].nameid < 1 )
 			continue;
-		if( (i_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL )
+		if( itemdb_exists(mob->dropitem[i].nameid) == NULL )
 			continue;
 
 		mapreg_setreg(add_str("$@MobDrop_item") + (j<<24), mob->dropitem[i].nameid);
@@ -10039,10 +10038,9 @@ BUILDIN_FUNC(divorce)
 BUILDIN_FUNC(ispartneron)
 {
 	TBL_PC *sd=script_rid2sd(st);
-	TBL_PC *p_sd=NULL;
 
 	if(sd==NULL || !pc_ismarried(sd) ||
-            (p_sd=map_charid2sd(sd->status.partner_id)) == NULL) {
+            map_charid2sd(sd->status.partner_id) == NULL) {
 		script_pushint(st,0);
 		return 0;
 	}
@@ -11352,12 +11350,9 @@ BUILDIN_FUNC(movenpc)
  *------------------------------------------*/
 BUILDIN_FUNC(message)
 {
-	TBL_PC *sd;
 	const char *msg,*player;
 	TBL_PC *pl_sd = NULL;
 
-	sd = script_rid2sd(st);
-
 	player = script_getstr(st,2);
 	msg = script_getstr(st,3);
 

+ 1 - 9
src/map/skill.c

@@ -323,9 +323,6 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, int skill
 // Making plagiarize check its own function [Aru]
 int can_copy (struct map_session_data *sd, int skillid, struct block_list* bl)
 {
-	struct status_change* sc;
-	sc = status_get_sc(bl);
-
 	// Never copy NPC/Wedding Skills
 	if (skill_get_inf2(skillid)&(INF2_NPC_SKILL|INF2_WEDDING_SKILL))
 		return 0;
@@ -2483,7 +2480,7 @@ static int skill_reveal_trap (struct block_list *bl, va_list ap)
  *------------------------------------------*/
 int skill_castend_damage_id (struct block_list* src, struct block_list *bl, int skillid, int skilllv, unsigned int tick, int flag)
 {
-	struct map_session_data *sd = NULL, *tsd = NULL;
+	struct map_session_data *sd = NULL;
 	struct status_data *tstatus;
 	struct status_change *sc;
 
@@ -2499,7 +2496,6 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, int
 		return 1;
 
 	sd = BL_CAST(BL_PC, src);
-	tsd = BL_CAST(BL_PC, bl);
 
 	if (status_isdead(bl))
 		return 1;
@@ -7408,7 +7404,6 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
 {
 	struct skill_unit_group *sg;
 	struct block_list *ss;
-	TBL_PC* sd;
 	TBL_PC* tsd;
 	struct status_data *tstatus, *sstatus;
 	struct status_change *tsc, *sc;
@@ -7425,7 +7420,6 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
 
 	nullpo_ret(sg=src->group);
 	nullpo_ret(ss=map_id2bl(sg->src_id));
-	sd = BL_CAST(BL_PC, ss);
 	tsd = BL_CAST(BL_PC, bl);
 	tsc = status_get_sc(bl);
 	tstatus = status_get_status_data(bl);
@@ -9041,11 +9035,9 @@ int skill_castfix (struct block_list *bl, int skill_id, int skill_lv)
 {
 	int time = skill_get_cast(skill_id, skill_lv);
 	struct map_session_data *sd;
-	struct status_change *sc;
 
 	nullpo_ret(bl);
 	sd = BL_CAST(BL_PC, bl);
-	sc = status_get_sc(bl);
 
 	// calculate base cast time (reduced by dex)
 	if( !(skill_get_castnodex(skill_id, skill_lv)&1) )

+ 0 - 4
src/map/status.c

@@ -7326,7 +7326,6 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr data)
  *------------------------------------------*/
 int status_change_timer_sub(struct block_list* bl, va_list ap)
 {
-	struct map_session_data *sd, *tsd;
 	struct status_change* tsc;
 
 	struct block_list* src = va_arg(ap,struct block_list*);
@@ -7339,9 +7338,6 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
 
 	tsc = status_get_sc(bl);
 
-	sd = BL_CAST(BL_PC, src);
-	tsd = BL_CAST(BL_PC, bl);
-
 	switch( type )
 	{
 	case SC_SIGHT:	/* ƒTƒCƒg */