summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-09 22:42:56 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-09 22:42:56 +0000
commitf3753f1cd474a84748b88991f74bcaa4f590f4ff (patch)
tree4e0f2fae76761e1b7e267f81f946f68da28b1f2a /src/map
parentb397f7c6615f68f044100168eeaf157f6c60227c (diff)
downloadhercules-f3753f1cd474a84748b88991f74bcaa4f590f4ff.tar.gz
hercules-f3753f1cd474a84748b88991f74bcaa4f590f4ff.tar.bz2
hercules-f3753f1cd474a84748b88991f74bcaa4f590f4ff.tar.xz
hercules-f3753f1cd474a84748b88991f74bcaa4f590f4ff.zip
Replaced several 'int' variables with enums that they represent.
Expanded weapon_type enum with dual-wield constants (bugreport:384). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11704 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/guild.c2
-rw-r--r--src/map/pc.c34
-rw-r--r--src/map/pc.h20
-rw-r--r--src/map/script.c12
-rw-r--r--src/map/script.h2
-rw-r--r--src/map/skill.c18
-rw-r--r--src/map/status.c7
7 files changed, 52 insertions, 43 deletions
diff --git a/src/map/guild.c b/src/map/guild.c
index e111a91c3..4bf006e5b 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -553,6 +553,8 @@ int guild_recv_info(struct guild *sg)
guild_check_member(sg);
if ((sd = map_nick2sd(sg->master)) != NULL)
{
+ //If the guild master is online the first time the guild_info is received,
+ //that means he was the first to join, so apply guild skill blocking here.
if( battle_config.guild_skill_relog_delay )
guild_block_skill(sd, 300000);
diff --git a/src/map/pc.c b/src/map/pc.c
index 0163c21e7..f07165776 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -439,25 +439,26 @@ int pc_calcweapontype(struct map_session_data *sd)
{
nullpo_retr(0, sd);
+ // single-hand
if(sd->weapontype1 != W_FIST && sd->weapontype2 == W_FIST)
sd->status.weapon = sd->weapontype1;
- else if(sd->weapontype1 == W_FIST && sd->weapontype2 != W_FIST)// 左手武器 Only
+ else if(sd->weapontype1 == W_FIST && sd->weapontype2 != W_FIST)
sd->status.weapon = sd->weapontype2;
- else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_DAGGER)// ?短?
- sd->status.weapon = MAX_WEAPON_TYPE+1;
- else if(sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_1HSWORD)// ??手?
- sd->status.weapon = MAX_WEAPON_TYPE+2;
- else if(sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_1HAXE)// ??手斧
- sd->status.weapon = MAX_WEAPON_TYPE+3;
- else if( (sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_1HSWORD) ||
- (sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_DAGGER) ) // 短? - ?手?
- sd->status.weapon = MAX_WEAPON_TYPE+4;
- else if( (sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_1HAXE) ||
- (sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_DAGGER) ) // 短? - 斧
- sd->status.weapon = MAX_WEAPON_TYPE+5;
- else if( (sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_1HAXE) ||
- (sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_1HSWORD) ) // ?手? - 斧
- sd->status.weapon = MAX_WEAPON_TYPE+6;
+ // dual-wield, matching types
+ else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_DAGGER)
+ sd->status.weapon = W_DOUBLE_DD;
+ else if(sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_1HSWORD)
+ sd->status.weapon = W_DOUBLE_SS;
+ else if(sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_1HAXE)
+ sd->status.weapon = W_DOUBLE_AA;
+ // dual-wield, mixed types
+ else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_1HSWORD || sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_DAGGER)
+ sd->status.weapon = W_DOUBLE_DS;
+ else if(sd->weapontype1 == W_DAGGER && sd->weapontype2 == W_1HAXE || sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_DAGGER)
+ sd->status.weapon = W_DOUBLE_DA;
+ else if(sd->weapontype1 == W_1HSWORD && sd->weapontype2 == W_1HAXE || sd->weapontype1 == W_1HAXE && sd->weapontype2 == W_1HSWORD)
+ sd->status.weapon = W_DOUBLE_SA;
+ // unknown, default to left hand type
else
sd->status.weapon = sd->weapontype1;
@@ -885,6 +886,7 @@ int pc_reg_received(struct map_session_data *sd)
{
// set the Guild Master flag
sd->state.gmaster_flag = g;
+ // prevent Guild Skills from being used directly after relog
if( battle_config.guild_skill_relog_delay )
guild_block_skill(sd, 300000);
}
diff --git a/src/map/pc.h b/src/map/pc.h
index de220d54c..1c8b191d9 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -16,7 +16,7 @@
//Total number of classes (for data storage)
#define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
-enum {
+enum weapon_type {
W_FIST, //Bare hands
W_DAGGER, //1
W_1HSWORD, //2
@@ -26,7 +26,7 @@ enum {
W_1HAXE, //6
W_2HAXE, //7
W_MACE, //8
- W_UNKNOWN, //View 9 seems unused anywhere
+ W_2HMACE, //9, unused?
W_STAFF, //10
W_BOW, //11
W_KNUCKLE, //12
@@ -40,8 +40,15 @@ enum {
W_GATLING, //20
W_GRENADE, //21
W_HUUMA, //22
- MAX_WEAPON_TYPE
-} weapon_type;
+ MAX_WEAPON_TYPE,
+ // dual-wield constants
+ W_DOUBLE_DD, // 2 daggers
+ W_DOUBLE_SS, // 2 swords
+ W_DOUBLE_AA, // 2 axes
+ W_DOUBLE_DS, // dagger + sword
+ W_DOUBLE_DA, // dagger + axe
+ W_DOUBLE_SA, // sword + axe
+};
enum {
A_ARROW = 1,
@@ -52,8 +59,9 @@ enum {
A_SHURIKEN, //6
A_KUNAI //7
} ammo_type;
+
//Equip position constants
-enum {
+enum equip_pos {
EQP_HEAD_LOW = 0x0001,
EQP_HEAD_MID = 0x0200, //512
EQP_HEAD_TOP = 0x0100, //256
@@ -65,7 +73,7 @@ enum {
EQP_ACC_L = 0x0008,
EQP_ACC_R = 0x0080, //128
EQP_AMMO = 0x8000, //32768
-} equip_pos_enum;
+};
#define EQP_WEAPON EQP_HAND_R
#define EQP_SHIELD EQP_HAND_L
diff --git a/src/map/script.c b/src/map/script.c
index 71aee9d6f..d9a0faead 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -153,7 +153,7 @@ static int script_pos,script_size;
static char *str_buf;
static int str_pos,str_size;
static struct str_data_struct {
- int type;
+ enum c_op type;
int str;
int backpatch;
int label;
@@ -201,12 +201,13 @@ enum curly_type {
TYPE_USERFUNC,
TYPE_ARGLIST // function argument list
};
+
#define ARGLIST_UNDEFINED 0
#define ARGLIST_NO_PAREN 1
#define ARGLIST_PAREN 2
static struct {
struct {
- int type;
+ enum curly_type type;
int index;
int count;
int flag;
@@ -215,13 +216,14 @@ static struct {
int curly_count; // 右カッコの数
int index; // スクリプト内で使用した構文の数
} syntax;
+
const char* parse_curly_close(const char* p);
const char* parse_syntax_close(const char* p);
const char* parse_syntax_close_sub(const char* p,int* flag);
const char* parse_syntax(const char* p);
static int parse_syntax_for_flag = 0;
-extern int current_equip_item_index; //for New CARS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus]
+extern int current_equip_item_index; //for New CARDS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus]
int potion_flag=0; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0;
int potion_target=0;
@@ -11672,7 +11674,6 @@ BUILDIN_FUNC(getd)
{
char varname[100];
const char *buffer;
- //struct script_data dat;
int elem;
buffer = script_getstr(st, 2);
@@ -11681,8 +11682,7 @@ BUILDIN_FUNC(getd)
elem = 0;
// Push the 'pointer' so it's more flexible [Lance]
- push_val(st->stack,C_NAME,
- (elem<<24) | add_str(varname));
+ push_val(st->stack, C_NAME, (elem<<24) | add_str(varname));
return 0;
}
diff --git a/src/map/script.h b/src/map/script.h
index 709577c6d..46a2b2910 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -26,7 +26,7 @@ extern struct Script_Config {
} script_config;
struct script_data {
- int type;
+ enum c_op type;
union script_data_val {
int num;
char *str;
diff --git a/src/map/skill.c b/src/map/skill.c
index 15c49c915..943548c91 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -1890,15 +1890,11 @@ static int skill_check_condition_hom (struct homun_data *hd, int skill, int lv,
if (!sc->count)
sc = NULL;
- // for the guild skills [celest]
- if (skill >= HM_SKILLBASE) //[orn]
- j = HM_SKILLRANGEMIN + skill - HM_SKILLBASE;
- else
- j = skill;
- if (j < 0 || j >= MAX_SKILL_DB)
- return 0;
//Code speedup, rather than using skill_get_* over and over again.
- if (lv < 1 || lv > MAX_SKILL_LEVEL)
+ j = skill_get_index(skill);
+ if( j == 0 )
+ return 0;
+ if( lv < 1 || lv > MAX_SKILL_LEVEL )
return 0;
for(i = 0; i < 10; i++) {
@@ -7510,13 +7506,13 @@ int skill_check_condition(struct map_session_data* sd, short skill, short lv, in
return 1;
}
+ //Code speedup, rather than using skill_get_* over and over again.
j = skill_get_index(skill);
- if (j == 0) // invalid skill id
+ if( j == 0 ) // invalid skill id
return 0;
- if (lv < 1 || lv > MAX_SKILL_LEVEL)
+ if( lv < 1 || lv > MAX_SKILL_LEVEL )
return 0;
- //Code speedup, rather than using skill_get_* over and over again.
hp = skill_db[j].hp[lv-1];
sp = skill_db[j].sp[lv-1];
if((sd->skillid_old == BD_ENCORE) && skill == sd->skillid_dance)
diff --git a/src/map/status.c b/src/map/status.c
index e59bdc88a..137e65158 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -7330,16 +7330,17 @@ int status_readdb(void)
i = 0;
while(fgets(line, sizeof(line), fp))
{
- char *split[MAX_WEAPON_TYPE + 5];
+ //NOTE: entry MAX_WEAPON_TYPE is not counted
+ char* split[5 + MAX_WEAPON_TYPE];
i++;
if(line[0]=='/' && line[1]=='/')
continue;
- for(j=0,p=line;j<(MAX_WEAPON_TYPE + 5) && p;j++){ //not 22 anymore [blackhole89]
+ for(j=0,p=line; j < 5 + MAX_WEAPON_TYPE && p; j++){
split[j]=p;
p=strchr(p,',');
if(p) *p++=0;
}
- if(j < MAX_WEAPON_TYPE + 5)
+ if(j < 5 + MAX_WEAPON_TYPE)
{ //Weapon #.MAX_WEAPON_TYPE is constantly not load. Fix to that: replace < with <= [blackhole89]
ShowDebug("%s: Not enough columns at line %d\n", path, i);
continue;