summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/const.txt6
-rw-r--r--src/map/chat.h4
-rw-r--r--src/map/clif.c10
-rw-r--r--src/map/script.c95
-rw-r--r--src/map/script.h3
-rw-r--r--src/map/status.h1
6 files changed, 92 insertions, 27 deletions
diff --git a/db/const.txt b/db/const.txt
index 577fbc2fc..8b4e5027b 100644
--- a/db/const.txt
+++ b/db/const.txt
@@ -299,12 +299,6 @@ EAJ_BABY_SURA 0x6204
EAJ_BABY_GENETIC 0x6205
EAJ_BABY_CHASER 0x6206
-Option_Wedding 0x1000
-Option_Xmas 0x10000
-Option_Summer 0x40000
-Option_Wug 0x100000
-Option_Wugrider 0x200000
-
bc_all 0
bc_map 1
bc_area 2
diff --git a/src/map/chat.h b/src/map/chat.h
index 71e5a11ec..b0c6cd905 100644
--- a/src/map/chat.h
+++ b/src/map/chat.h
@@ -10,6 +10,8 @@
struct map_session_data;
struct chat_data;
+#define MAX_CHAT_USERS 20
+
struct chat_data {
struct block_list bl; // data for this map object
char title[CHATROOM_TITLE_SIZE]; // room title
@@ -21,7 +23,7 @@ struct chat_data {
uint32 zeny; // required zeny to join
uint32 minLvl; // minimum base level to join
uint32 maxLvl; // maximum base level allowed to join
- struct map_session_data* usersd[20];
+ struct map_session_data* usersd[MAX_CHAT_USERS];
struct block_list* owner;
char npc_event[EVENT_NAME_LENGTH];
/* isn't this a waste? there is a enormous overhead, wouldn't something like skill_blockpc_start be better here? [Ind] */
diff --git a/src/map/clif.c b/src/map/clif.c
index a3541cab9..36adbae9c 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -818,7 +818,7 @@ void clif_clearunit_delayed(struct block_list* bl, clr_type type, int64 tick) {
/// Gets weapon view info from sd's inventory_data and points (*rhand,*lhand)
void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand)
{
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST)) {
+ if(sd->sc.option&OPTION_COSTUME) {
*rhand = *lhand = 0;
return;
}
@@ -3209,7 +3209,7 @@ void clif_changelook(struct block_list *bl,int type,int val)
case LOOK_BASE:
if( !sd ) break;
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST) )
+ if( sd->sc.option&OPTION_COSTUME )
vd->weapon = vd->shield = 0;
if( !vd->cloth_color )
@@ -10086,7 +10086,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
if( pc_cant_act(sd) || sd->sc.option&OPTION_HIDE )
return;
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST) )
+ if( sd->sc.option&OPTION_COSTUME )
return;
if( sd->sc.data[SC_BASILICA] || sd->sc.data[SC__SHADOWFORM] ||
@@ -11331,7 +11331,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
}
}
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST) )
+ if( sd->sc.option&OPTION_COSTUME )
return;
if( sd->sc.data[SC_BASILICA] && (skill_id != HP_BASILICA || sd->sc.data[SC_BASILICA]->val4 != sd->bl.id) )
@@ -11423,7 +11423,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
}
}
- if( sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST) )
+ if( sd->sc.option&OPTION_COSTUME )
return;
if( sd->sc.data[SC_BASILICA] && (skill_id != HP_BASILICA || sd->sc.data[SC_BASILICA]->val4 != sd->bl.id) )
diff --git a/src/map/script.c b/src/map/script.c
index 0887b7f4e..03ebb80a3 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4321,6 +4321,7 @@ void do_init_script(bool minimal) {
script->parse_builtin();
script->read_constdb();
+ script->hardcoded_constants();
if (minimal)
return;
@@ -5059,7 +5060,7 @@ BUILDIN(warp)
else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0)
ret = pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
else
- ret = pc->setpos(sd,mapindex->name2id(str),x,y,CLR_OUTSIGHT);
+ ret = pc->setpos(sd,script->mapindexname2id(st,str),x,y,CLR_OUTSIGHT);
if( ret ) {
ShowError("buildin_warp: moving player '%s' to \"%s\",%d,%d failed.\n", sd->status.name, str, x, y);
@@ -5136,7 +5137,7 @@ BUILDIN(areawarp)
if( strcmp(str,"Random") == 0 )
index = 0;
- else if( !(index=mapindex->name2id(str)) )
+ else if( !(index=script->mapindexname2id(st,str)) )
return true;
map->foreachinarea(script->buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3);
@@ -5200,7 +5201,7 @@ BUILDIN(warpchar) {
if(strcmp(str, "SavePoint") == 0)
pc->setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
else
- pc->setpos(sd, mapindex->name2id(str), x, y, CLR_TELEPORT);
+ pc->setpos(sd, script->mapindexname2id(st,str), x, y, CLR_TELEPORT);
return true;
}
@@ -5248,7 +5249,7 @@ BUILDIN(warpparty)
y = pl_sd->bl.y;
break;
case 4:
- map_index = mapindex->name2id(str);
+ map_index = script->mapindexname2id(st,str);
break;
case 2:
//"SavePoint" uses save point of the currently attached player
@@ -5346,7 +5347,7 @@ BUILDIN(warpguild)
break;
case 3: // m,x,y
if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp)
- pc->setpos(pl_sd,mapindex->name2id(str),x,y,CLR_TELEPORT);
+ pc->setpos(pl_sd,script->mapindexname2id(st,str),x,y,CLR_TELEPORT);
break;
}
}
@@ -8546,7 +8547,7 @@ BUILDIN(savepoint) {
str = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
- mapid = mapindex->name2id(str);
+ mapid = script->mapindexname2id(st,str);
if( mapid )
pc->setsavepoint(sd, mapid, x, y);
@@ -10629,7 +10630,7 @@ BUILDIN(warpwaitingpc) {
else if( strcmp(map_name,"SavePoint") == 0 )
pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
else
- pc->setpos(sd, mapindex->name2id(map_name), x, y, CLR_OUTSIGHT);
+ pc->setpos(sd, script->mapindexname2id(st,map_name), x, y, CLR_OUTSIGHT);
}
mapreg->setreg(script->add_str("$@warpwaitingpcnum"), i);
return true;
@@ -10699,7 +10700,7 @@ BUILDIN(setmapflagnosave) {
x=script_getnum(st,4);
y=script_getnum(st,5);
m = map->mapname2mapid(str);
- map_index = mapindex->name2id(str2);
+ map_index = script->mapindexname2id(st,str2);
if(m >= 0 && map_index) {
map->list[m].flag.nosave=1;
@@ -11541,7 +11542,7 @@ BUILDIN(mapwarp) {
if((m=map->mapname2mapid(mapname))< 0)
return true;
- if(!(index=mapindex->name2id(str)))
+ if(!(index=script->mapindexname2id(st,str)))
return true;
switch(check_val) {
@@ -11727,7 +11728,7 @@ BUILDIN(warppartner)
x=script_getnum(st,3);
y=script_getnum(st,4);
- map_index = mapindex->name2id(str);
+ map_index = script->mapindexname2id(st,str);
if (map_index) {
pc->setpos(p_sd,map_index,x,y,CLR_OUTSIGHT);
script_pushint(st,1);
@@ -15688,7 +15689,7 @@ BUILDIN(warpportal) {
spx = script_getnum(st,2);
spy = script_getnum(st,3);
- map_index = mapindex->name2id(script_getstr(st, 4));
+ map_index = script->mapindexname2id(st,script_getstr(st, 4));
tpx = script_getnum(st,5);
tpy = script_getnum(st,6);
@@ -16141,7 +16142,7 @@ BUILDIN(waitingroom2bg) {
map_name = script_getstr(st,2);
if( strcmp(map_name,"-") != 0 )
{
- map_index = mapindex->name2id(map_name);
+ map_index = script->mapindexname2id(st,map_name);
if( map_index == 0 )
{ // Invalid Map
script_pushint(st,0);
@@ -16183,7 +16184,7 @@ BUILDIN(waitingroom2bg_single) {
bg_id = script_getnum(st,2);
map_name = script_getstr(st,3);
- if( (map_index = mapindex->name2id(map_name)) == 0 )
+ if( (map_index = script->mapindexname2id(st,map_name)) == 0 )
return true; // Invalid Map
x = script_getnum(st,4);
@@ -16228,7 +16229,7 @@ BUILDIN(bg_warp)
bg_id = script_getnum(st,2);
map_name = script_getstr(st,3);
- if( (map_index = mapindex->name2id(map_name)) == 0 )
+ if( (map_index = script->mapindexname2id(st,map_name)) == 0 )
return true; // Invalid Map
x = script_getnum(st,4);
y = script_getnum(st,5);
@@ -18006,7 +18007,7 @@ BUILDIN(bg_create_team) {
map_name = script_getstr(st,2);
if( strcmp(map_name,"-") != 0 ) {
- map_index = mapindex->name2id(map_name);
+ map_index = script->mapindexname2id(st,map_name);
if( map_index == 0 ) { // Invalid Map
script_pushint(st,0);
return true;
@@ -19057,6 +19058,67 @@ void script_label_add(int key, int pos) {
script->label_count++;
}
+/**
+ * Sets source-end constants for scripts to play with
+ **/
+void script_hardcoded_constants(void) {
+
+ /* server defines */
+ script->set_constant("PACKETVER",PACKETVER,false);
+ script->set_constant("MAX_LEVEL",MAX_LEVEL,false);
+ script->set_constant("MAX_STORAGE",MAX_STORAGE,false);
+ script->set_constant("MAX_GUILD_STORAGE",MAX_GUILD_STORAGE,false);
+ script->set_constant("MAX_CART",MAX_INVENTORY,false);
+ script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false);
+ script->set_constant("MAX_ZENY",MAX_ZENY,false);
+ script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false);
+ script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false);
+
+ /* status options */
+ script->set_constant("Option_Nothing",OPTION_NOTHING,false);
+ script->set_constant("Option_Sight",OPTION_SIGHT,false);
+ script->set_constant("Option_Hide",OPTION_HIDE,false);
+ script->set_constant("Option_Cloak",OPTION_CLOAK,false);
+ script->set_constant("Option_Falcon",OPTION_FALCON,false);
+ script->set_constant("Option_Riding",OPTION_RIDING,false);
+ script->set_constant("Option_Invisible",OPTION_INVISIBLE,false);
+ script->set_constant("Option_Orcish",OPTION_ORCISH,false);
+ script->set_constant("Option_Wedding",OPTION_WEDDING,false);
+ script->set_constant("Option_Chasewalk",OPTION_CHASEWALK,false);
+ script->set_constant("Option_Flying",OPTION_FLYING,false);
+ script->set_constant("Option_Xmas",OPTION_XMAS,false);
+ script->set_constant("Option_Transform",OPTION_TRANSFORM,false);
+ script->set_constant("Option_Summer",OPTION_SUMMER,false);
+ script->set_constant("Option_Dragon1",OPTION_DRAGON1,false);
+ script->set_constant("Option_Wug",OPTION_WUG,false);
+ script->set_constant("Option_Wugrider",OPTION_WUGRIDER,false);
+ script->set_constant("Option_Madogear",OPTION_MADOGEAR,false);
+ script->set_constant("Option_Dragon2",OPTION_DRAGON2,false);
+ script->set_constant("Option_Dragon3",OPTION_DRAGON3,false);
+ script->set_constant("Option_Dragon4",OPTION_DRAGON4,false);
+ script->set_constant("Option_Dragon5",OPTION_DRAGON5,false);
+ script->set_constant("Option_Hanbok",OPTION_HANBOK,false);
+ script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false);
+
+ /* status option compounds */
+ script->set_constant("Option_Dragon",OPTION_DRAGON,false);
+ script->set_constant("Option_Costume",OPTION_COSTUME,false);
+}
+
+/**
+ * a mapindex_name2id wrapper meant to help with invalid name handling
+ **/
+unsigned short script_mapindexname2id (struct script_state *st, const char* name) {
+ unsigned short index;
+
+ if( !(index=mapindex->name2id(name)) ) {
+ script->reportsrc(st);
+ return 0;
+ }
+ return index;
+}
+
+
void script_defaults(void) {
// aegis->athena slot position conversion table
unsigned int equip[SCRIPT_EQUIP_TABLE_SIZE] = {EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_GARMENT,EQP_SHADOW_ARMOR, EQP_SHADOW_WEAPON, EQP_SHADOW_SHIELD, EQP_SHADOW_SHOES, EQP_SHADOW_ACC_R, EQP_SHADOW_ACC_L};
@@ -19308,5 +19370,8 @@ void script_defaults(void) {
/* */
script->generic_ui_array_expand = script_generic_ui_array_expand;
script->array_cpy_list = script_array_cpy_list;
+ /* */
+ script->hardcoded_constants = script_hardcoded_constants;
+ script->mapindexname2id = script_mapindexname2id;
}
diff --git a/src/map/script.h b/src/map/script.h
index 3835a130b..7ab7f17c6 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -694,6 +694,9 @@ struct script_interface {
/* */
void (*generic_ui_array_expand) (unsigned int plus);
unsigned int *(*array_cpy_list) (struct script_array *sa);
+ /* */
+ void (*hardcoded_constants) (void);
+ unsigned short (*mapindexname2id) (struct script_state *st, const char* name);
};
struct script_interface *script;
diff --git a/src/map/status.h b/src/map/status.h
index 06bea3908..c0c6c63b7 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -1592,6 +1592,7 @@ enum {
// compound constants
OPTION_DRAGON = OPTION_DRAGON1|OPTION_DRAGON2|OPTION_DRAGON3|OPTION_DRAGON4|OPTION_DRAGON5,
+ OPTION_COSTUME = OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST,
};
//Defines for the manner system [Skotlex]