Skip to content

Commit

Permalink
Changed battle_config definition to extern to avoid mistakes in plugins
Browse files Browse the repository at this point in the history
- This avoids plugins incorrectly using battle_config (with unreliable
  results) instead of using the proper interface, battle->bc.
- Edited various #defines to use battle->bc instead of battle_config so
  that they can work perperly in plugins as well.

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed May 16, 2014
1 parent fddd0a6 commit d350bfe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/map/battle.h
Expand Up @@ -21,12 +21,12 @@ struct status_data;
/**
* Defines
**/
#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)
#define MIN_HAIR_STYLE (battle->bc->min_hair_style)
#define MAX_HAIR_STYLE (battle->bc->max_hair_style)
#define MIN_HAIR_COLOR (battle->bc->min_hair_color)
#define MAX_HAIR_COLOR (battle->bc->max_hair_color)
#define MIN_CLOTH_COLOR (battle->bc->min_cloth_color)
#define MAX_CLOTH_COLOR (battle->bc->max_cloth_color)

#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru]

Expand Down Expand Up @@ -469,7 +469,9 @@ struct Battle_Config {
int mon_trans_disable_in_gvg;

int case_sensitive_aegisnames;
} battle_config;
};

extern struct Battle_Config battle_config;

/* criteria for battle_config.idletime_critera */
enum e_battle_config_idletime {
Expand Down
2 changes: 1 addition & 1 deletion src/map/map.h
Expand Up @@ -26,7 +26,7 @@ enum E_MAPSERVER_ST {
};

#define MAX_NPC_PER_MAP 512
#define AREA_SIZE (battle_config.area_size)
#define AREA_SIZE (battle->bc->area_size)
#define DAMAGELOG_SIZE 30
#define LOOTITEM_SIZE 10
#define MAX_MOBSKILL 50
Expand Down
8 changes: 4 additions & 4 deletions src/map/pc.h
Expand Up @@ -7,7 +7,7 @@

#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT

#include "battle.h" // battle_config
#include "battle.h" // battle
#include "battleground.h" // enum bg_queue_types
#include "buyingstore.h" // struct s_buyingstore
#include "itemdb.h" // MAX_ITEMDELAYS
Expand Down Expand Up @@ -565,7 +565,7 @@ struct map_session_data {
#define pc_setsit(sd) ( (sd)->state.dead_sit = (sd)->vd.dead_sit = 2 )
#define pc_isdead(sd) ( (sd)->state.dead_sit == 1 )
#define pc_issit(sd) ( (sd)->vd.dead_sit == 2 )
#define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(sockt->last_tick, (sd)->idletime) >= battle_config.idle_no_share )
#define pc_isidle(sd) ( (sd)->chatID || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(sockt->last_tick, (sd)->idletime) >= battle->bc->idle_no_share )
#define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading )
#define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chatID || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend )

Expand All @@ -587,9 +587,9 @@ struct map_session_data {
#define pc_isfalcon(sd) ( (sd)->sc.option&OPTION_FALCON )
#define pc_isriding(sd) ( (sd)->sc.option&OPTION_RIDING )
#define pc_isinvisible(sd) ( (sd)->sc.option&OPTION_INVISIBLE )
#define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle_config.natural_heal_weight_rate )
#define pc_is50overweight(sd) ( (sd)->weight*100 >= (sd)->max_weight*battle->bc->natural_heal_weight_rate )
#define pc_is90overweight(sd) ( (sd)->weight*10 >= (sd)->max_weight*9 )
#define pc_maxparameter(sd) ( (((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO || ((sd)->class_&MAPID_UPPERMASK) == MAPID_REBELLION || ((sd)->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E) ? battle_config.max_extended_parameter : (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle_config.max_baby_third_parameter : battle_config.max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter) )
#define pc_maxparameter(sd) ( (((sd)->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO || ((sd)->class_&MAPID_UPPERMASK) == MAPID_REBELLION || ((sd)->class_&MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E) ? battle->bc->max_extended_parameter : (sd)->class_&JOBL_THIRD ? ((sd)->class_&JOBL_BABY ? battle->bc->max_baby_third_parameter : battle->bc->max_third_parameter) : ((sd)->class_&JOBL_BABY ? battle->bc->max_baby_parameter : battle->bc->max_parameter) )
/**
* Ranger
**/
Expand Down

0 comments on commit d350bfe

Please sign in to comment.