summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-29 09:53:45 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-29 09:53:45 +0000
commit9e62c33d9ee58d7dcf1c667a77b3fdd814bc0943 (patch)
tree872a0cc972ddfc74e17afff9efc4065dc284401b /src
parent3b0f07f4b6d7ba237ba37a7d4ce627ded5581cad (diff)
downloadhercules-9e62c33d9ee58d7dcf1c667a77b3fdd814bc0943.tar.gz
hercules-9e62c33d9ee58d7dcf1c667a77b3fdd814bc0943.tar.bz2
hercules-9e62c33d9ee58d7dcf1c667a77b3fdd814bc0943.tar.xz
hercules-9e62c33d9ee58d7dcf1c667a77b3fdd814bc0943.zip
[Optimized]
- Removed unused checks for unsigned data type and possible logic error for char type (gcc treats char as unsigned). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6814 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/common/grfio.c2
-rw-r--r--src/common/showmsg.c2
-rw-r--r--src/common/socket.c2
-rw-r--r--src/map/atcommand.c7
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/irc.c2
-rw-r--r--src/map/map.c2
-rw-r--r--src/map/npc.c3
-rw-r--r--src/map/pc.c8
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/status.c2
-rw-r--r--src/map/status.h2
-rw-r--r--src/map/vending.c2
13 files changed, 16 insertions, 22 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 41e6864ae..aa677a0e5 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -68,7 +68,7 @@ typedef struct {
char type;
char fn[128-4*5]; // file name
char *fnd;
- char gentry; // read grf file select
+ signed char gentry; // read grf file select
} FILELIST;
//gentry ... 0 : It acquires from a local file.
// It acquires from the resource file of 1>=:gentry_table[gentry-1].
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 7d940b189..03dcb7e8a 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -52,7 +52,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
return 1;
}
- if (timestamp_format)
+ if (strlen(timestamp_format) > 0)
{ //Display time format. [Skotlex]
time_t t = time(NULL);
strftime(prefix, 80, timestamp_format, localtime(&t));
diff --git a/src/common/socket.c b/src/common/socket.c
index 2558e83ac..8fba86e0e 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -1210,7 +1210,7 @@ int RFIFOSKIP(int fd,int len)
s = session[fd];
- if (s->rdata_size-s->rdata_pos-len<0) {
+ if ((signed int)(s->rdata_size-s->rdata_pos-len)<0) {
//fprintf(stderr,"too many skip\n");
//exit(1);
//better than a COMPLETE program abort // TEST! :)
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 40c957ae6..4b61c5f74 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2466,7 +2466,7 @@ int atcommand_kami(
return -1;
}
- if(color < 0 || color > 0xFFFFFF) {
+ if(color > 0xFFFFFF) {
clif_displaymessage(fd, "Invalid color.");
return -1;
}
@@ -6199,9 +6199,6 @@ char * txt_time(unsigned int duration) {
memset(temp, '\0', sizeof(temp));
memset(temp1, '\0', sizeof(temp1));
- if (duration < 0)
- duration = 0;
-
days = duration / (60 * 60 * 24);
duration = duration - (60 * 60 * 24 * days);
hours = duration / (60 * 60);
@@ -7770,7 +7767,7 @@ int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* co
rate = atoi(message) * 100;
// check for invalid value
- if(rate < 0 || rate > 10000)
+ if(rate > 10000)
{
clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
return 0;
diff --git a/src/map/battle.c b/src/map/battle.c
index b0b953827..71c5c8411 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -1614,7 +1614,7 @@ static struct Damage battle_calc_weapon_attack(
if (!flag.idef || !flag.idef2)
{ //Defense reduction
short vit_def;
- char def1 = (char)status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
+ signed char def1 = (signed char)status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
short def2 = (short)tstatus->def2;
if(battle_config.vit_penalty_type)
{
diff --git a/src/map/irc.c b/src/map/irc.c
index 2ddc70c5e..1d1b41617 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -129,7 +129,7 @@ void irc_announce_mvp(struct map_session_data *sd, struct mob_data *md)
memset(send_string,'\0',256);
memset(mapname,'\0',16);
- mapname[16]='\0';
+ mapname[15]='\0'; // 15 is the final index, not 16 [Lance]
strcpy(mapname, map[md->bl.m].name);
maplen = strcspn(mapname,".");
mapname[maplen] = '\0';
diff --git a/src/map/map.c b/src/map/map.c
index 3833acb34..1952acb45 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2162,7 +2162,7 @@ int map_getcell(int m,int x,int y,cell_t cellchk)
return (m < 0 || m >= MAX_MAP_PER_SERVER) ? 0 : map_getcellp(&map[m],x,y,cellchk);
}
-int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk)
+int map_getcellp(struct map_data* m,int x,int y,int cellchk)
{
int type, type2;
#ifdef CELL_NOSTACK
diff --git a/src/map/npc.c b/src/map/npc.c
index a81e371c7..93fc25e04 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -15,6 +15,7 @@
#include "../common/grfio.h"
#include "../common/showmsg.h"
#include "../common/ers.h"
+#include "../common/db.h"
#include "map.h"
#include "log.h"
#include "npc.h"
@@ -2193,7 +2194,7 @@ int npc_parse_mob (char *w1, char *w2, char *w3, char *w4)
if (sscanf(w3, "%23[^,],%d", mobname, &level) > 1)
mob.level = level;
- if( mob.delay1<0 || mob.delay2<0 || mob.delay1>0xfffffff || mob.delay2>0xfffffff) {
+ if(mob.delay1>0xfffffff || mob.delay2>0xfffffff) {
ShowError("wrong monsters spawn delays : %s %s (file %s)\n", w3, w4, current_file);
return 1;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index ccd066c0c..3a573f97f 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3842,7 +3842,7 @@ int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int jo
//Overflow checks... think we'll ever really need'em? [Skotlex]
if (base_exp > 0 && sd->status.base_exp > UINT_MAX - base_exp)
sd->status.base_exp = UINT_MAX;
- else if (base_exp < 0 && sd->status.base_exp > base_exp)
+ else if (sd->status.base_exp > base_exp)
sd->status.base_exp = 0;
else
sd->status.base_exp += base_exp;
@@ -3854,7 +3854,7 @@ int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int jo
//Overflow checks... think we'll ever really need'em? [Skotlex]
if (job_exp > 0 && sd->status.job_exp > UINT_MAX - job_exp)
sd->status.job_exp = UINT_MAX;
- else if (job_exp < 0 && sd->status.job_exp > job_exp)
+ else if (sd->status.job_exp > job_exp)
sd->status.job_exp = 0;
else
sd->status.job_exp += job_exp;
@@ -4933,16 +4933,12 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
case SP_BASEEXP:
if(pc_nextbaseexp(sd) > 0) {
sd->status.base_exp = val;
- if(sd->status.base_exp < 0)
- sd->status.base_exp=0;
pc_checkbaselevelup(sd);
}
break;
case SP_JOBEXP:
if(pc_nextjobexp(sd) > 0) {
sd->status.job_exp = val;
- if(sd->status.job_exp < 0)
- sd->status.job_exp=0;
pc_checkjoblevelup(sd);
}
break;
diff --git a/src/map/script.c b/src/map/script.c
index c4d79e7a1..f0ce4f200 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -8171,7 +8171,7 @@ int buildin_petskillbonus(struct script_state *st)
pd->bonus->duration=conv_num(st,& (st->stack->stack_data[st->start+4]));
pd->bonus->delay=conv_num(st,& (st->stack->stack_data[st->start+5]));
- if (pd->state.skillbonus == -1)
+ if (pd->state.skillbonus == 1)
pd->state.skillbonus=0; // waiting state
// wait for timer to start
diff --git a/src/map/status.c b/src/map/status.c
index 24821895a..09170ee92 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -629,7 +629,7 @@ int status_heal(struct block_list *bl,unsigned int hp,unsigned int sp, int flag)
//If rates are > 0, percent is of current HP/SP
//If rates are < 0, percent is of max HP/SP
//If flag, this is heal, otherwise it is damage.
-int status_percent_change(struct block_list *src,struct block_list *target,char hp_rate, char sp_rate, int flag)
+int status_percent_change(struct block_list *src,struct block_list *target,signed char hp_rate, signed char sp_rate, int flag)
{
struct status_data *status;
unsigned int hp =0, sp = 0;
diff --git a/src/map/status.h b/src/map/status.h
index 21688df56..f4523100b 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -508,7 +508,7 @@ int status_damage(struct block_list *src,struct block_list *target,unsigned int
#define status_zap(bl, hp, sp) status_damage(NULL, bl, hp, sp, 0, 1)
//Define for standard HP/SP skill-related cost triggers (mobs require no HP/SP to use skills)
#define status_charge(bl, hp, sp) ((bl)->type != BL_PC || status_damage(NULL, bl, hp, sp, 0, 3))
-int status_percent_change(struct block_list *src,struct block_list *target,char hp_rate, char sp_rate, int flag);
+int status_percent_change(struct block_list *src,struct block_list *target,signed char hp_rate, signed char sp_rate, int flag);
//Easier handling of status_percent_change
#define status_percent_heal(bl, hp_rate, sp_rate) status_percent_change(NULL, bl, -(hp_rate), -(sp_rate), 1)
#define status_percent_damage(src, target, hp_rate, sp_rate) status_percent_change(src, target, hp_rate, sp_rate, 0)
diff --git a/src/map/vending.c b/src/map/vending.c
index 607cdc890..38f5c848e 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -240,7 +240,7 @@ void vending_openvending(struct map_session_data *sd,int len,char *message,int f
else if(sd->vending[i].value < 1)
sd->vending[i].value = 1000000; // auto set to 1 million [celest]
// カート内のアイテム数と販売するアイテム数に相違があったら中止
- if(pc_cartitem_amount(sd, sd->vending[i].index, sd->vending[i].amount) < 0 || sd->vending[i].value < 0) { // fixes by Valaris and fritz
+ if(pc_cartitem_amount(sd, sd->vending[i].index, sd->vending[i].amount) < 0) { // fixes by Valaris and fritz
clif_skill_fail(sd, MC_VENDING, 0, 0);
return;
}