summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorgepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-04 18:37:29 +0000
committergepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-04 18:37:29 +0000
commit262e60ab0b9cfc1f942a7b3ef11f7ed3abc7b208 (patch)
tree82cb02f8048521c7479ff012511a066612f6d439 /src/map/script.c
parentce4352cfef6f07bf3b4c0324f48f880c5c74f041 (diff)
downloadhercules-262e60ab0b9cfc1f942a7b3ef11f7ed3abc7b208.tar.gz
hercules-262e60ab0b9cfc1f942a7b3ef11f7ed3abc7b208.tar.bz2
hercules-262e60ab0b9cfc1f942a7b3ef11f7ed3abc7b208.tar.xz
hercules-262e60ab0b9cfc1f942a7b3ef11f7ed3abc7b208.zip
- Guild Castle code cleanup:
- removed `MAX_GUILDCASTLE` limit - char-server now caches guild castles in `DBMap` - improved guild castle SQL queries to support non-default values of `MAX_GUARDIANS` - disallowed declaring guild castles on maps that are on other map-servers - map-server now requests data for all guild castles from char-server on initial connect (bugreport:287) - removed ''guildcastleinfo events'' as they were esentially duplicated ''OnAgitInit'' - optimized castle data load packets (bugreport:287) - updated WoE scripts to reflect source changes (scripts no longer need or should request castle or guild data) - updated related docs - Added `db_size` macro. - Replaced manual counting of castles occupied by a guild with `guild_checkcastles()` calls. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15657 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c138
1 files changed, 66 insertions, 72 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 29387fe4e..67e9e722e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10139,52 +10139,44 @@ BUILDIN_FUNC(getcastlename)
BUILDIN_FUNC(getcastledata)
{
- const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
+ const char *mapname = mapindex_getmapname(script_getstr(st,2),NULL);
int index = script_getnum(st,3);
+ struct guild_castle *gc = guild_mapname2gc(mapname);
- struct guild_castle* gc = guild_mapname2gc(mapname);
+ if (gc == NULL) {
+ script_pushint(st,0);
+ ShowWarning("builtin_setcastledata: guild castle for map '%s' not found\n", mapname);
+ return 1;
+ }
- if(script_hasdata(st,4) && index==0 && gc) {
- const char* event = script_getstr(st,4);
- check_event(st, event);
- guild_addcastleinfoevent(gc->castle_id, 9+MAX_GUARDIANS, event);
- }
-
- if(gc){
- switch(index){
- case 0: {
- int i;
- for (i = 1; i <= 9+MAX_GUARDIANS; i++) // Initialize[AgitInit]
- guild_castledataload(gc->castle_id,i);
- } break;
- case 1:
- script_pushint(st,gc->guild_id); break;
- case 2:
- script_pushint(st,gc->economy); break;
- case 3:
- script_pushint(st,gc->defense); break;
- case 4:
- script_pushint(st,gc->triggerE); break;
- case 5:
- script_pushint(st,gc->triggerD); break;
- case 6:
- script_pushint(st,gc->nextTime); break;
- case 7:
- script_pushint(st,gc->payTime); break;
- case 8:
- script_pushint(st,gc->createTime); break;
- case 9:
- script_pushint(st,gc->visibleC); break;
- default:
- if (index > 9 && index <= 9+MAX_GUARDIANS)
- script_pushint(st,gc->guardian[index-10].visible);
- else
- script_pushint(st,0);
+ switch (index) {
+ case 1:
+ script_pushint(st,gc->guild_id); break;
+ case 2:
+ script_pushint(st,gc->economy); break;
+ case 3:
+ script_pushint(st,gc->defense); break;
+ case 4:
+ script_pushint(st,gc->triggerE); break;
+ case 5:
+ script_pushint(st,gc->triggerD); break;
+ case 6:
+ script_pushint(st,gc->nextTime); break;
+ case 7:
+ script_pushint(st,gc->payTime); break;
+ case 8:
+ script_pushint(st,gc->createTime); break;
+ case 9:
+ script_pushint(st,gc->visibleC); break;
+ default:
+ if (index > 9 && index <= 9+MAX_GUARDIANS) {
+ script_pushint(st,gc->guardian[index-10].visible);
break;
- }
- return 0;
+ }
+ script_pushint(st,0);
+ ShowWarning("buildin_setcastledata: index = '%d' is out of allowed range\n", index);
+ return 1;
}
- script_pushint(st,0);
return 0;
}
@@ -10193,39 +10185,41 @@ BUILDIN_FUNC(setcastledata)
const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
int index = script_getnum(st,3);
int value = script_getnum(st,4);
-
struct guild_castle* gc = guild_mapname2gc(mapname);
- if(gc) {
- // Save Data byself First
- switch(index){
- case 1:
- gc->guild_id = value; break;
- case 2:
- gc->economy = value; break;
- case 3:
- gc->defense = value; break;
- case 4:
- gc->triggerE = value; break;
- case 5:
- gc->triggerD = value; break;
- case 6:
- gc->nextTime = value; break;
- case 7:
- gc->payTime = value; break;
- case 8:
- gc->createTime = value; break;
- case 9:
- gc->visibleC = value; break;
- default:
- if (index > 9 && index <= 9+MAX_GUARDIANS) {
- gc->guardian[index-10].visible = value;
- break;
- }
- return 0;
- }
- guild_castledatasave(gc->castle_id,index,value);
+ if (gc == NULL) {
+ ShowWarning("builtin_setcastledata: guild castle for map '%s' not found\n", mapname);
+ return 1;
+ }
+
+ switch (index) {
+ case 1:
+ gc->guild_id = value; break;
+ case 2:
+ gc->economy = value; break;
+ case 3:
+ gc->defense = value; break;
+ case 4:
+ gc->triggerE = value; break;
+ case 5:
+ gc->triggerD = value; break;
+ case 6:
+ gc->nextTime = value; break;
+ case 7:
+ gc->payTime = value; break;
+ case 8:
+ gc->createTime = value; break;
+ case 9:
+ gc->visibleC = value; break;
+ default:
+ if (index > 9 && index <= 9+MAX_GUARDIANS) {
+ gc->guardian[index-10].visible = value;
+ break;
+ }
+ ShowWarning("buildin_setcastledata: index = '%d' is out of allowed range\n", index);
+ return 1;
}
+ guild_castledatasave(gc->castle_id, index, value);
return 0;
}
@@ -16065,7 +16059,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(agitcheck,""), // <Agitcheck>
BUILDIN_DEF(flagemblem,"i"), // Flag Emblem
BUILDIN_DEF(getcastlename,"s"),
- BUILDIN_DEF(getcastledata,"si?"),
+ BUILDIN_DEF(getcastledata,"si"),
BUILDIN_DEF(setcastledata,"sii"),
BUILDIN_DEF(requestguildinfo,"i?"),
BUILDIN_DEF(getequipcardcnt,"i"),