Merge pull request #2466 from rathena/refactor/mob_cpp
* Convert mob.c to mob.cpp.
This commit is contained in:
commit
aa6e8987db
@ -233,7 +233,9 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="mapreg.c" />
|
||||
<ClCompile Include="mercenary.c" />
|
||||
<ClCompile Include="mob.c" />
|
||||
<ClCompile Include="mob.cpp">
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
</ClCompile>
|
||||
<ClCompile Include="npc.c" />
|
||||
<ClCompile Include="npc_chat.c" />
|
||||
<ClCompile Include="party.c" />
|
||||
|
@ -217,7 +217,7 @@
|
||||
<ClCompile Include="mercenary.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mob.c">
|
||||
<ClCompile Include="mob.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="npc.c">
|
||||
|
@ -29,6 +29,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode.
|
||||
|
||||
#define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME)
|
||||
@ -580,7 +584,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, unsigned int size, unsigned int ai)
|
||||
struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, unsigned int size, enum mob_ai ai)
|
||||
{
|
||||
struct spawn_data data;
|
||||
|
||||
@ -622,7 +626,7 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int
|
||||
/*==========================================
|
||||
* Spawn a single mob on the specified coordinates.
|
||||
*------------------------------------------*/
|
||||
int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, unsigned int ai)
|
||||
int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai)
|
||||
{
|
||||
struct mob_data* md = NULL;
|
||||
int count, lv;
|
||||
@ -674,7 +678,7 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const
|
||||
/*==========================================
|
||||
* Spawn mobs in the specified area.
|
||||
*------------------------------------------*/
|
||||
int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, unsigned int ai)
|
||||
int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai)
|
||||
{
|
||||
int i, max, id = 0;
|
||||
int lx = -1, ly = -1;
|
||||
@ -1228,7 +1232,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
|
||||
nullpo_ret(bl);
|
||||
md=va_arg(ap,struct mob_data *);
|
||||
target= va_arg(ap,struct block_list**);
|
||||
mode= va_arg(ap,enum e_mode);
|
||||
mode= static_cast<enum e_mode>(va_arg(ap, int));
|
||||
|
||||
//If can't seek yet, not an enemy, or you can't attack it, skip.
|
||||
if ((*target) == bl || !status_check_skilluse(&md->bl, bl, 0, 0))
|
||||
@ -3764,7 +3768,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
|
||||
if (mode) //User provided mode.
|
||||
status->mode = mode;
|
||||
else if (flag&1) //Friendly Character, remove looting.
|
||||
status->mode &= ~MD_LOOTER;
|
||||
status->mode = static_cast<enum e_mode>(status->mode&(~MD_LOOTER));
|
||||
status->hp = status->max_hp;
|
||||
status->sp = status->max_sp;
|
||||
memcpy(&db->vd, &sd->vd, sizeof(struct view_data));
|
||||
@ -4125,9 +4129,9 @@ static bool mob_parse_dbrow(char** str)
|
||||
return false;
|
||||
}
|
||||
|
||||
status->mode = (int)strtol(str[25], NULL, 0);
|
||||
status->mode = static_cast<enum e_mode>(strtol(str[25], NULL, 0));
|
||||
if (!battle_config.monster_active_enable)
|
||||
status->mode &= ~MD_AGGRESSIVE;
|
||||
status->mode = static_cast<enum e_mode>(status->mode&(~MD_AGGRESSIVE));
|
||||
|
||||
if (status_has_mode(status,MD_STATUS_IMMUNE|MD_KNOCKBACK_IMMUNE|MD_DETECTOR))
|
||||
status->class_ = CLASS_BOSS;
|
||||
@ -4279,7 +4283,7 @@ static int mob_read_sqldb(void)
|
||||
// free the query result
|
||||
Sql_FreeResult(mmysql_handle);
|
||||
|
||||
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]);
|
||||
ShowStatus("Done reading '" CL_WHITE "%lu" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", count, mob_db_name[fi]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -4719,13 +4723,14 @@ static int mob_read_sqlskilldb(void)
|
||||
while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) {
|
||||
// wrap the result into a TXT-compatible format
|
||||
char* str[19];
|
||||
char* dummy = "";
|
||||
char dummy[255] = "";
|
||||
int i;
|
||||
++lines;
|
||||
for( i = 0; i < 19; ++i )
|
||||
{
|
||||
Sql_GetData(mmysql_handle, i, &str[i], NULL);
|
||||
if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns
|
||||
if( str[i] == NULL )
|
||||
str[i] = dummy; // get rid of NULL columns
|
||||
}
|
||||
|
||||
if (!mob_parse_row_mobskilldb(str, 19, count))
|
||||
@ -4737,7 +4742,7 @@ static int mob_read_sqlskilldb(void)
|
||||
// free the query result
|
||||
Sql_FreeResult(mmysql_handle);
|
||||
|
||||
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]);
|
||||
ShowStatus("Done reading '" CL_WHITE "%lu" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", count, mob_skill_db_name[fi]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -5170,7 +5175,7 @@ static void mob_load(void)
|
||||
int i;
|
||||
const char* dbsubpath[] = {
|
||||
"",
|
||||
"/"DBIMPORT,
|
||||
"/" DBIMPORT,
|
||||
};
|
||||
|
||||
// First we parse all the possible monsters to add additional data in the second loop
|
||||
@ -5244,8 +5249,8 @@ void mob_db_load(bool is_reload){
|
||||
if( !is_reload ) {
|
||||
// on mobdbreload it's not neccessary to execute this
|
||||
// item ers needs to be allocated only once
|
||||
item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_CLEAN);
|
||||
item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE);
|
||||
item_drop_ers = ers_new(sizeof(struct item_drop),"mob.cpp::item_drop_ers",ERS_OPT_CLEAN);
|
||||
item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.cpp::item_drop_list_ers",ERS_OPT_NONE);
|
||||
}
|
||||
mob_item_drop_ratio = idb_alloc(DB_OPT_BASE);
|
||||
mob_skill_db = idb_alloc(DB_OPT_BASE);
|
||||
@ -5375,3 +5380,8 @@ void do_final_mob(bool is_reload){
|
||||
ers_destroy(item_drop_list_ers);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -302,13 +302,13 @@ struct view_data* mob_get_viewdata(int mob_id);
|
||||
void mob_set_dynamic_viewdata( struct mob_data* md );
|
||||
void mob_free_dynamic_viewdata( struct mob_data* md );
|
||||
|
||||
struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, unsigned int size, unsigned int ai);
|
||||
struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, unsigned int size, enum mob_ai ai);
|
||||
|
||||
int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y,
|
||||
const char* mobname, int mob_id, int amount, const char* event, unsigned int size, unsigned int ai);
|
||||
const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai);
|
||||
|
||||
int mob_once_spawn_area(struct map_session_data* sd, int16 m,
|
||||
int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, unsigned int ai);
|
||||
int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai);
|
||||
|
||||
bool mob_ksprotected (struct block_list *src, struct block_list *target);
|
||||
|
||||
|
@ -10186,7 +10186,7 @@ BUILDIN_FUNC(monster)
|
||||
int amount = script_getnum(st,7);
|
||||
const char* event = "";
|
||||
unsigned int size = SZ_SMALL;
|
||||
unsigned int ai = AI_NONE;
|
||||
enum mob_ai ai = AI_NONE;
|
||||
|
||||
struct map_session_data* sd;
|
||||
int16 m;
|
||||
@ -10206,7 +10206,7 @@ BUILDIN_FUNC(monster)
|
||||
}
|
||||
|
||||
if (script_hasdata(st, 10)) {
|
||||
ai = script_getnum(st, 10);
|
||||
ai = static_cast<enum mob_ai>(script_getnum(st, 10));
|
||||
if (ai >= AI_MAX) {
|
||||
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
@ -10287,7 +10287,7 @@ BUILDIN_FUNC(areamonster)
|
||||
int amount = script_getnum(st,9);
|
||||
const char* event = "";
|
||||
unsigned int size = SZ_SMALL;
|
||||
unsigned int ai = AI_NONE;
|
||||
enum mob_ai ai = AI_NONE;
|
||||
|
||||
struct map_session_data* sd;
|
||||
int16 m;
|
||||
@ -10307,7 +10307,7 @@ BUILDIN_FUNC(areamonster)
|
||||
}
|
||||
|
||||
if (script_hasdata(st, 12)) {
|
||||
ai = script_getnum(st, 12);
|
||||
ai = static_cast<enum mob_ai>(script_getnum(st, 12));
|
||||
if (ai >= AI_MAX) {
|
||||
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user