summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/map/script.c b/src/map/script.c
index ec68e2b9f..8412d0019 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9576,42 +9576,33 @@ BUILDIN_FUNC(flagemblem)
BUILDIN_FUNC(getcastlename)
{
- char mapname[MAP_NAME_LENGTH_EXT];
- struct guild_castle *gc;
-
- strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH_EXT);
- gc = guild_mapname2gc(mapname);
-
- if(gc)
- script_pushconststr(st,gc->castle_name);
- else
- script_pushconststr(st,"");
+ const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
+ struct guild_castle* gc = guild_mapname2gc(mapname);
+ char* name = (gc) ? gc->castle_name : "";
+ script_pushconststr(st,name);
return 0;
}
BUILDIN_FUNC(getcastledata)
{
- char mapname[MAP_NAME_LENGTH_EXT];
- int index=script_getnum(st,3);
- const char *event=NULL;
- struct guild_castle *gc;
- int i;
+ const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
+ int index = script_getnum(st,3);
- strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH_EXT);
- gc = guild_mapname2gc(mapname);
+ struct guild_castle* gc = guild_mapname2gc(mapname);
if(script_hasdata(st,4) && index==0 && gc) {
- event=script_getstr(st,4);
+ const char* event = script_getstr(st,4);
check_event(st, event);
guild_addcastleinfoevent(gc->castle_id,17,event);
}
if(gc){
switch(index){
- case 0:
+ case 0: {
+ int i;
for(i=1;i<26;i++) // Initialize[AgitInit]
guild_castledataload(gc->castle_id,i);
- break;
+ } break;
case 1:
script_pushint(st,gc->guild_id); break;
case 2:
@@ -9659,13 +9650,10 @@ BUILDIN_FUNC(getcastledata)
BUILDIN_FUNC(setcastledata)
{
- char mapname[MAP_NAME_LENGTH_EXT];
int index=script_getnum(st,3);
int value=script_getnum(st,4);
- struct guild_castle *gc;
-
- strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH_EXT);
- gc = guild_mapname2gc(mapname);
+
+ struct guild_castle* gc = guild_mapname2gc( mapindex_getmapname(script_getstr(st,2),NULL) );
if(gc) {
// Save Data byself First