From 2ce4ea3324da64930c77076194e2e8b2b8ab2e49 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sat, 18 Dec 2010 12:48:56 +0000 Subject: * Updates to handling of hair color/style and cloth color of characters. - Moved limit shortcut defines from mmo.h to battle.h, as they are only required in files, which include battle.h (since pre-svn 2004/10/15). - Moved hair style/color validation from char-server to map-server. This enables use of non-default limits as specified in battle config, rather than being restricted to hard-coded ones (bugreport:150). - Cleaned up related capping of values in pc_changelook (related r1708). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14604 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 ++++ src/char/char.c | 2 -- src/char_sql/char.c | 2 -- src/common/mmo.h | 7 ------- src/map/battle.h | 7 +++++++ src/map/pc.c | 35 +++++++++++++++++++++++------------ 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 06d895800..4f1ceedb2 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,10 @@ Date Added 2010/12/18 + * Updates to handling of hair color/style and cloth color of characters. [Ai4rei] + - Moved limit shortcut defines from mmo.h to battle.h, as they are only required in files, which include battle.h (since pre-svn 2004/10/15). + - Moved hair style/color validation from char-server to map-server. This enables use of non-default limits as specified in battle config, rather than being restricted to hard-coded ones (bugreport:150). + - Cleaned up related capping of values in pc_changelook (related r1708). * Fixed usage of literals for map name length in character list packet (since r14368). [Ai4rei] 2010/12/17 * Made the 'player not attached' script error also report the function it occured in, if available. [Ai4rei] diff --git a/src/char/char.c b/src/char/char.c index c61a84d29..31eb5c7dc 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1194,8 +1194,6 @@ int make_new_char(struct char_session_data* sd, char* name_, int str, int agi, i //check other inputs if((slot >= MAX_CHARS) // slots - || (hair_style >= 24) // hair style - || (hair_color >= 9) // hair color || (str + agi + vit + int_ + dex + luk != 6*5 ) // stats || (str < 1 || str > 9 || agi < 1 || agi > 9 || vit < 1 || vit > 9 || int_ < 1 || int_ > 9 || dex < 1 || dex > 9 || luk < 1 || luk > 9) // individual stat values || (str + int_ != 10 || agi + luk != 10 || vit + dex != 10) ) // pairs diff --git a/src/char_sql/char.c b/src/char_sql/char.c index d33ba46bd..b96027490 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -1294,8 +1294,6 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag //check other inputs if((slot >= MAX_CHARS) // slots - || (hair_style >= 24) // hair style - || (hair_color >= 9) // hair color || (str + agi + vit + int_ + dex + luk != 6*5 ) // stats || (str < 1 || str > 9 || agi < 1 || agi > 9 || vit < 1 || vit > 9 || int_ < 1 || int_ > 9 || dex < 1 || dex > 9 || luk < 1 || luk > 9) // individual stat values || (str + int_ != 10 || agi + luk != 10 || vit + dex != 10) ) // pairs diff --git a/src/common/mmo.h b/src/common/mmo.h index d2bc93a04..994a1d6a2 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -108,13 +108,6 @@ #define MAX_QUEST_DB 2000 //Max quests that the server will load #define MAX_QUEST_OBJECTIVES 3 //Max quest objectives for a quest -#define MIN_HAIR_STYLE battle_config.min_hair_style -#define MAX_HAIR_STYLE battle_config.max_hair_style -#define MIN_HAIR_COLOR battle_config.min_hair_color -#define MAX_HAIR_COLOR battle_config.max_hair_color -#define MIN_CLOTH_COLOR battle_config.min_cloth_color -#define MAX_CLOTH_COLOR battle_config.max_cloth_color - // for produce #define MIN_ATTRIBUTE 0 #define MAX_ATTRIBUTE 4 diff --git a/src/map/battle.h b/src/map/battle.h index 79ea13b1c..1a879f5b5 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -96,6 +96,13 @@ bool battle_check_range(struct block_list *src,struct block_list *bl,int range); void battle_consume_ammo(struct map_session_data* sd, int skill, int lv); // ݒ +#define MIN_HAIR_STYLE battle_config.min_hair_style +#define MAX_HAIR_STYLE battle_config.max_hair_style +#define MIN_HAIR_COLOR battle_config.min_hair_color +#define MAX_HAIR_COLOR battle_config.max_hair_color +#define MIN_CLOTH_COLOR battle_config.min_cloth_color +#define MAX_CLOTH_COLOR battle_config.max_cloth_color + extern struct Battle_Config { int warp_point_debug; diff --git a/src/map/pc.c b/src/map/pc.c index 018b392f1..45064794b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -840,6 +840,23 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim sd->class_ = MAPID_NOVICE; } else sd->class_ = i; + + // Checks and fixes to character status data, that are required + // in case of configuration change or stuff, which cannot be + // checked on char-server. + if( sd->status.hair < MIN_HAIR_STYLE || sd->status.hair > MAX_HAIR_STYLE ) + { + sd->status.hair = MIN_HAIR_STYLE; + } + if( sd->status.hair_color < MIN_HAIR_COLOR || sd->status.hair_color > MAX_HAIR_COLOR ) + { + sd->status.hair_color = MIN_HAIR_COLOR; + } + if( sd->status.clothes_color < MIN_CLOTH_COLOR || sd->status.clothes_color > MAX_CLOTH_COLOR ) + { + sd->status.clothes_color = MIN_CLOTH_COLOR; + } + //Initializations to null/0 unneeded since map_session_data was filled with 0 upon allocation. if(!sd->status.hp) pc_setdead(sd); sd->state.connect_new = 1; @@ -6334,10 +6351,8 @@ int pc_changelook(struct map_session_data *sd,int type,int val) switch(type){ case LOOK_HAIR: //Use the battle_config limits! [Skotlex] - if (val < battle_config.min_hair_style) - val = battle_config.min_hair_style; - else if (val > battle_config.max_hair_style) - val = battle_config.max_hair_style; + val = cap_value(val, MIN_HAIR_STYLE, MAX_HAIR_STYLE); + if (sd->status.hair != val) { sd->status.hair=val; @@ -6359,10 +6374,8 @@ int pc_changelook(struct map_session_data *sd,int type,int val) sd->status.head_mid=val; break; case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex] - if (val < battle_config.min_hair_color) - val = battle_config.min_hair_color; - else if (val > battle_config.max_hair_color) - val = battle_config.max_hair_color; + val = cap_value(val, MIN_HAIR_COLOR, MAX_HAIR_COLOR); + if (sd->status.hair_color != val) { sd->status.hair_color=val; @@ -6372,10 +6385,8 @@ int pc_changelook(struct map_session_data *sd,int type,int val) } break; case LOOK_CLOTHES_COLOR: //Use the battle_config limits! [Skotlex] - if (val < battle_config.min_cloth_color) - val = battle_config.min_cloth_color; - else if (val > battle_config.max_cloth_color) - val = battle_config.max_cloth_color; + val = cap_value(val, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); + sd->status.clothes_color=val; break; case LOOK_SHIELD: -- cgit v1.2.3-60-g2f50