Replaced several 'int' variables with enums that they represent.

Expanded weapon_type enum with dual-wield constants (bugreport:384).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11704 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2007-11-09 22:42:56 +00:00
parent 376a1f68ba
commit 5eda6c0e57
9 changed files with 58 additions and 46 deletions

View File

@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/11/09
* Expanded weapon_type enum with dual-wield constants (bugreport:384)
* Replaced several 'int' variables with enums that they represent
* Re-worked the login-char-map packet spam mechanism
- mapserver no longer sends entire user list to charserver every
10 seconds; similar change done to the char-login connection

View File

@ -111,14 +111,14 @@ struct item {
int id;
short nameid;
short amount;
unsigned short equip;
unsigned short equip; // location(s) where item is equipped (using enum equip_pos for bitmasking)
char identify;
char refine;
char attribute;
short card[MAX_SLOTS];
};
struct point{
struct point {
unsigned short map;
short x,y;
};
@ -217,7 +217,8 @@ struct mmo_charstatus {
int party_id,guild_id,pet_id,hom_id;
int fame;
short weapon,shield;
enum weapon_type weapon;
short shield; // view-id
short head_top,head_mid,head_bottom;
char name[NAME_LENGTH];

View File

@ -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);

View File

@ -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)// Ť¶Žč•<C48D>Ší 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)// ?Z?
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) ) // Z? - ?Žč?
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) ) // Z? - •€
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);
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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;