summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-07-09 20:19:32 -0300
committershennetsind <ind@henn.et>2013-07-09 20:19:32 -0300
commitb08910e828bd6f2029f2434572d8f84b30eb7d9c (patch)
tree28932ba60514fd0483aa5d88e0fa8a43200cac3c
parent55d42874dcf24c466f0104123d9efe280c0fd03c (diff)
downloadhercules-b08910e828bd6f2029f2434572d8f84b30eb7d9c.tar.gz
hercules-b08910e828bd6f2029f2434572d8f84b30eb7d9c.tar.bz2
hercules-b08910e828bd6f2029f2434572d8f84b30eb7d9c.tar.xz
hercules-b08910e828bd6f2029f2434572d8f84b30eb7d9c.zip
Travis Report Fixes
warn_unused_result shielding, dropped unused variables and fixed battle_calc_return_damage delay behavior (pointer was unchaged; resulting in the var afterwards always as 0) Special Thanks to Xgear. Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r--src/common/core.c6
-rw-r--r--src/common/utils.c15
-rw-r--r--src/common/utils.h3
-rw-r--r--src/map/battle.c55
-rw-r--r--src/map/itemdb.c64
-rw-r--r--src/map/script.c8
6 files changed, 79 insertions, 72 deletions
diff --git a/src/common/core.c b/src/common/core.c
index d2f662551..1e5179448 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -150,11 +150,6 @@ void signals_init (void) {
}
#endif
-#ifdef SVNVERSION
-const char *get_svn_revision(void) {
- return EXPAND_AND_QUOTE(SVNVERSION);
-}
-#else// not SVNVERSION
const char* get_svn_revision(void) {
static char svn_version_buffer[16] = "";
FILE *fp;
@@ -241,7 +236,6 @@ const char* get_svn_revision(void) {
svn_version_buffer[0] = HERC_UNKNOWN_VER;
return svn_version_buffer;
}
-#endif
/* whats our origin */
#define GIT_ORIGIN "refs/remotes/origin/master"
/* Grabs the hash from the last time the user updated his working copy (last pull) */
diff --git a/src/common/utils.c b/src/common/utils.c
index 4d6d35c5c..30649e2f5 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -344,8 +344,8 @@ FILE *HCache_open(const char *file, const char *opt) {
if( opt[0] != 'r' ) {
char dT[1] = "k";/* 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */
- fwrite(dT,sizeof(dT),1,first);
- fwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first);
+ hwrite(dT,sizeof(dT),1,first);
+ hwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first);
}
fseek(first, 20, SEEK_SET);/* skip first 20, might wanna store something else later */
@@ -365,10 +365,19 @@ void HCache_init(void) {
} else
ShowWarning("Unable to open '%s', caching capabilities have been disabled!\n",SERVER_NAME);
}
+/* transit to fread, shields vs warn_unused_result */
+size_t hread(void * ptr, size_t size, size_t count, FILE * stream) {
+ return fread(ptr, size, count, stream);
+}
+/* transit to fwrite, shields vs warn_unused_result */
+size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream) {
+ return fwrite(ptr, size, count, stream);
+}
+
void HCache_defaults(void) {
HCache = &HCache_s;
-
+
HCache->init = HCache_init;
HCache->check = HCache_check;
diff --git a/src/common/utils.h b/src/common/utils.h
index d245f94e2..b1fb4e3a0 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -31,6 +31,9 @@ extern uint16 GetWord(uint32 val, int idx);
extern uint16 MakeWord(uint8 byte0, uint8 byte1);
extern uint32 MakeDWord(uint16 word0, uint16 word1);
+size_t hread(void * ptr, size_t size, size_t count, FILE * stream);
+size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream);
+
/* [Ind/Hercules] Caching */
struct HCache_interface {
void (*init) (void);
diff --git a/src/map/battle.c b/src/map/battle.c
index 0530510c4..135247734 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -838,21 +838,17 @@ int battle_calc_masteryfix(struct block_list *src, struct block_list *target, ui
* Elemental attribute fix.
*------------------------------------------*/
int battle_calc_elefix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int nk, int n_ele, int s_ele, int s_ele_, bool left, int flag){
- struct status_data *sstatus, *tstatus;
- struct status_change *sc;
-
+ struct status_data *tstatus;
+
nullpo_ret(src);
nullpo_ret(target);
- sstatus = iStatus->get_status_data(src);
tstatus = iStatus->get_status_data(target);
- sc = iStatus->get_sc(src);
-
+
if( (nk&NK_NO_ELEFIX) || n_ele )
return damage;
- if( damage > 0 )
- {
+ if( damage > 0 ) {
if( left )
damage = battle->attr_fix(src, target, damage, s_ele_, tstatus->def_ele, tstatus->ele_lv);
else{
@@ -863,14 +859,22 @@ int battle_calc_elefix(struct block_list *src, struct block_list *target, uint16
damage += battle_attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
}
}
+
#ifndef RENEWAL
- if( sc && sc->data[SC_SUB_WEAPONPROPERTY] )
- { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex]
- int temp = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
- damage += battle->attr_fix(src, target, temp, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
- if( left ){
- temp = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
+ {
+ struct status_data *sstatus;
+ struct status_change *sc;
+
+ sstatus = iStatus->get_status_data(src);
+ sc = iStatus->get_sc(src);
+
+ if( sc && sc->data[SC_SUB_WEAPONPROPERTY] ) { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex]
+ int temp = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
damage += battle->attr_fix(src, target, temp, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
+ if( left ) {
+ temp = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100;
+ damage += battle->attr_fix(src, target, temp, sc->data[SC_SUB_WEAPONPROPERTY]->val1, tstatus->def_ele, tstatus->ele_lv);
+ }
}
}
#endif
@@ -3210,8 +3214,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
unsigned int skillratio = 100; //Skill dmg modifiers.
TBL_PC *sd;
-// TBL_PC *tsd;
- struct status_change *sc, *tsc;
+ struct status_change *sc;
struct Damage ad;
struct status_data *sstatus = iStatus->get_status_data(src);
struct status_data *tstatus = iStatus->get_status_data(target);
@@ -3240,9 +3243,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
flag.imdef = nk&NK_IGNORE_DEF?1:0;
sd = BL_CAST(BL_PC, src);
-// tsd = BL_CAST(BL_PC, target);
+
sc = iStatus->get_sc(src);
- tsc = iStatus->get_sc(target);
//Initialize variables that will be used afterwards
s_ele = skill->get_ele(skill_id, skill_lv);
@@ -3929,7 +3931,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
{
unsigned int skillratio = 100; //Skill dmg modifiers.
short temp=0;
- short s_ele, s_ele_, t_class;
+ short s_ele, s_ele_;
int i, nk;
bool n_ele = false; // non-elemental
@@ -4095,7 +4097,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
return wd;
}
- t_class = iStatus->get_class(target);
s_ele = s_ele_ = skill->get_ele(skill_id, skill_lv);
if( !skill_id || s_ele == -1 )
{ //Take weapon's element
@@ -5167,7 +5168,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
//Calculates BF_WEAPON returned damage.
int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int *dmg, int flag, uint16 skill_id, int *delay){
- int rdamage = 0, damage = *dmg, rdelay = *delay, trdamage = 0;
+ int rdamage = 0, damage = *dmg, trdamage = 0;
struct map_session_data* sd;
struct status_change* sc;
int max_reflect_damage;
@@ -5194,18 +5195,18 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int
if( flag & BF_SHORT) {//Bounces back part of the damage.
if ( sd && sd->bonus.short_weapon_damage_return ){
NORMALIZE_RDAMAGE(damage * sd->bonus.short_weapon_damage_return / 100);
- rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
if( sc && sc->count ) {
if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ){
NORMALIZE_RDAMAGE(damage * sc->data[SC_REFLECTSHIELD]->val2 / 100);
- rdelay = clif->skill_damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4);
+ *delay = clif->skill_damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4);
}
if( sc->data[SC_LG_REFLECTDAMAGE] && rand()%100 < (30 + 10*sc->data[SC_LG_REFLECTDAMAGE]->val1) ) {
if( skill_id != HT_LANDMINE && skill_id != HT_CLAYMORETRAP
&& skill_id != RA_CLUSTERBOMB && (skill_id <= RA_VERDURETRAP || skill_id > RA_ICEBOUNDTRAP) && skill_id != MA_LANDMINE ){
NORMALIZE_RDAMAGE((*dmg) * sc->data[SC_LG_REFLECTDAMAGE]->val2 / 100);
- rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
}
if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) {
@@ -5219,18 +5220,18 @@ int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int
skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit_getdir(src), 0);
if( skill_id )
status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER);
- rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
}
if( sc->data[SC_SHIELDSPELL_DEF] && sc->data[SC_SHIELDSPELL_DEF]->val1 == 2 && !is_boss(src) ){
NORMALIZE_RDAMAGE(damage * sc->data[SC_SHIELDSPELL_DEF]->val2 / 100);
- rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
}
} else {
if (sd && sd->bonus.long_weapon_damage_return){
NORMALIZE_RDAMAGE(damage * sd->bonus.long_weapon_damage_return / 100);
- rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 5dee2bb00..e703ead68 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -720,31 +720,31 @@ void itemdb_write_cached_packages(const char *config_filename) {
}
// first 2 bytes = package count
- fwrite(&pcount,sizeof(pcount),1,file);
+ hwrite(&pcount,sizeof(pcount),1,file);
for(i = 0; i < pcount; i++) {
unsigned short id = itemdb->packages[i].id, random_qty = itemdb->packages[i].random_qty, must_qty = itemdb->packages[i].must_qty;
unsigned short c;
//into a package, first 2 bytes = id.
- fwrite(&id,sizeof(id),1,file);
+ hwrite(&id,sizeof(id),1,file);
//next 2 bytes = must count
- fwrite(&must_qty,sizeof(must_qty),1,file);
+ hwrite(&must_qty,sizeof(must_qty),1,file);
//next 2 bytes = random count
- fwrite(&random_qty,sizeof(random_qty),1,file);
+ hwrite(&random_qty,sizeof(random_qty),1,file);
//now we loop into must
for(c = 0; c < must_qty; c++) {
struct item_package_must_entry *entry = &itemdb->packages[i].must_items[c];
unsigned char announce = entry->announce == 1 ? 1 : 0, named = entry->named == 1 ? 1 : 0;
//first 2 byte = item id
- fwrite(&entry->id,sizeof(entry->id),1,file);
+ hwrite(&entry->id,sizeof(entry->id),1,file);
//next 2 byte = qty
- fwrite(&entry->qty,sizeof(entry->qty),1,file);
+ hwrite(&entry->qty,sizeof(entry->qty),1,file);
//next 2 byte = hours
- fwrite(&entry->hours,sizeof(entry->hours),1,file);
+ hwrite(&entry->hours,sizeof(entry->hours),1,file);
//next 1 byte = announce (1:0)
- fwrite(&announce,sizeof(announce),1,file);
+ hwrite(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- fwrite(&named,sizeof(announce),1,file);
+ hwrite(&named,sizeof(announce),1,file);
}
//now we loop into random groups
for(c = 0; c < random_qty; c++) {
@@ -752,23 +752,23 @@ void itemdb_write_cached_packages(const char *config_filename) {
unsigned short group_qty = group->random_qty, h;
//next 2 bytes = how many entries in this group
- fwrite(&group_qty,sizeof(group_qty),1,file);
+ hwrite(&group_qty,sizeof(group_qty),1,file);
//now we loop into the group's list
for(h = 0; h < group_qty; h++) {
struct item_package_rand_entry *entry = &itemdb->packages[i].random_groups[c].random_list[h];
unsigned char announce = entry->announce == 1 ? 1 : 0, named = entry->named == 1 ? 1 : 0;
//first 2 byte = item id
- fwrite(&entry->id,sizeof(entry->id),1,file);
+ hwrite(&entry->id,sizeof(entry->id),1,file);
//next 2 byte = qty
- fwrite(&entry->qty,sizeof(entry->qty),1,file);
+ hwrite(&entry->qty,sizeof(entry->qty),1,file);
//next 2 byte = rate
- fwrite(&entry->rate,sizeof(entry->rate),1,file);
+ hwrite(&entry->rate,sizeof(entry->rate),1,file);
//next 2 byte = hours
- fwrite(&entry->hours,sizeof(entry->hours),1,file);
+ hwrite(&entry->hours,sizeof(entry->hours),1,file);
//next 1 byte = announce (1:0)
- fwrite(&announce,sizeof(announce),1,file);
+ hwrite(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- fwrite(&named,sizeof(announce),1,file);
+ hwrite(&named,sizeof(announce),1,file);
}
}
}
@@ -787,7 +787,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
}
// first 2 bytes = package count
- fread(&pcount,sizeof(pcount),1,file);
+ hread(&pcount,sizeof(pcount),1,file);
CREATE(itemdb->packages, struct item_package, pcount);
itemdb->package_count = pcount;
@@ -799,11 +799,11 @@ bool itemdb_read_cached_packages(const char *config_filename) {
unsigned short c;
//into a package, first 2 bytes = id.
- fread(&id,sizeof(id),1,file);
+ hread(&id,sizeof(id),1,file);
//next 2 bytes = must count
- fread(&must_qty,sizeof(must_qty),1,file);
+ hread(&must_qty,sizeof(must_qty),1,file);
//next 2 bytes = random count
- fread(&random_qty,sizeof(random_qty),1,file);
+ hread(&random_qty,sizeof(random_qty),1,file);
if( !(data = itemdb->exists(id)) )
ShowWarning("itemdb_read_packages: unknown package item '%d', skipping..\n",id);
@@ -825,15 +825,15 @@ bool itemdb_read_cached_packages(const char *config_filename) {
unsigned char announce = 0, named = 0;
struct item_data *data;
//first 2 byte = item id
- fread(&mid,sizeof(mid),1,file);
+ hread(&mid,sizeof(mid),1,file);
//next 2 byte = qty
- fread(&qty,sizeof(qty),1,file);
+ hread(&qty,sizeof(qty),1,file);
//next 2 byte = hours
- fread(&hours,sizeof(hours),1,file);
+ hread(&hours,sizeof(hours),1,file);
//next 1 byte = announce (1:0)
- fread(&announce,sizeof(announce),1,file);
+ hread(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- fread(&named,sizeof(announce),1,file);
+ hread(&named,sizeof(announce),1,file);
if( !(data = itemdb->exists(mid)) )
ShowWarning("itemdb_read_packages: unknown item '%d' in package '%s'!\n",mid,itemdb_name(package->id));
@@ -853,7 +853,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
struct item_package_rand_entry *prev = NULL;
//next 2 bytes = how many entries in this group
- fread(&group_qty,sizeof(group_qty),1,file);
+ hread(&group_qty,sizeof(group_qty),1,file);
package->random_groups[c].random_qty = group_qty;
CREATE(package->random_groups[c].random_list, struct item_package_rand_entry, package->random_groups[c].random_qty);
@@ -868,17 +868,17 @@ bool itemdb_read_cached_packages(const char *config_filename) {
if( prev ) prev->next = entry;
//first 2 byte = item id
- fread(&mid,sizeof(mid),1,file);
+ hread(&mid,sizeof(mid),1,file);
//next 2 byte = qty
- fread(&qty,sizeof(qty),1,file);
+ hread(&qty,sizeof(qty),1,file);
//next 2 byte = rate
- fread(&rate,sizeof(rate),1,file);
+ hread(&rate,sizeof(rate),1,file);
//next 2 byte = hours
- fread(&hours,sizeof(hours),1,file);
+ hread(&hours,sizeof(hours),1,file);
//next 1 byte = announce (1:0)
- fread(&announce,sizeof(announce),1,file);
+ hread(&announce,sizeof(announce),1,file);
//next 1 byte = named (1:0)
- fread(&named,sizeof(announce),1,file);
+ hread(&named,sizeof(announce),1,file);
if( !(data = itemdb->exists(mid)) )
ShowWarning("itemdb_read_packages: unknown item '%d' in package '%s'!\n",mid,itemdb_name(package->id));
diff --git a/src/map/script.c b/src/map/script.c
index b5edec220..3cb31b726 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10486,13 +10486,13 @@ BUILDIN(removemapflag)
{
int16 m,i;
const char *str;
- int val=0;
+ //int val=0;//warning: variable ‘val’ set but not used" - deprecated?
str=script_getstr(st,2);
i=script_getnum(st,3);
- if(script_hasdata(st,4)){
- val=script_getnum(st,4);
- }
+ //if(script_hasdata(st,4)){
+ // val=script_getnum(st,4);
+ //}
m = iMap->mapname2mapid(str);
if(m >= 0) {
switch(i) {