summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-06-20 17:56:01 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-06-20 17:56:01 +0000
commitef7452b497d24f6f475d214f1244ab589b304c7c (patch)
treec24bedb42ecf633efada0475417d7f0592d2e1ab /src/common
parent6f700c626efe9253ce77865667d1d5e598daab65 (diff)
downloadhercules-ef7452b497d24f6f475d214f1244ab589b304c7c.tar.gz
hercules-ef7452b497d24f6f475d214f1244ab589b304c7c.tar.bz2
hercules-ef7452b497d24f6f475d214f1244ab589b304c7c.tar.xz
hercules-ef7452b497d24f6f475d214f1244ab589b304c7c.zip
- Instancing System (Thanks to Sirius White who did most of the code, with some of my work to implement client side information, some optimizations and bugfixes). Also thanks to contributions from UEAUP team and Orcao.
- Fixed a bug on areamobuseskill and changed it to make it as Aegis. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13901 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/db.c15
-rw-r--r--src/common/db.h3
-rw-r--r--src/common/mapindex.c46
-rw-r--r--src/common/mapindex.h3
-rw-r--r--src/common/mmo.h2
5 files changed, 55 insertions, 14 deletions
diff --git a/src/common/db.c b/src/common/db.c
index 6506fb889..537f26e6a 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -2562,6 +2562,21 @@ void linkdb_insert( struct linkdb_node** head, void *key, void* data)
node->data = data;
}
+void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... )
+{
+ va_list args;
+ struct linkdb_node *node;
+
+ if( head == NULL ) return;
+
+ va_start(args, func);
+ node = *head;
+ while ( node ) {
+ func( node->key, node->data, args );
+ node = node->next;
+ }
+}
+
void* linkdb_search( struct linkdb_node** head, void *key)
{
int n = 0;
diff --git a/src/common/db.h b/src/common/db.h
index 15cf28295..c1b224bcd 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -774,11 +774,14 @@ struct linkdb_node {
void *data;
};
+typedef void (*LinkDBFunc)(void* key, void* data, va_list args);
+
void linkdb_insert ( struct linkdb_node** head, void *key, void* data); // 重複を考慮しない
void linkdb_replace( struct linkdb_node** head, void *key, void* data); // 重複を考慮する
void* linkdb_search ( struct linkdb_node** head, void *key);
void* linkdb_erase ( struct linkdb_node** head, void *key);
void linkdb_final ( struct linkdb_node** head );
+void linkdb_foreach( struct linkdb_node** head, LinkDBFunc func, ... );
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 72db1af6d..01843c936 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -47,17 +47,22 @@ const char* mapindex_getmapname(const char* string, char* output)
/// Result gets placed either into 'buf' or in a static local buffer.
const char* mapindex_getmapname_ext(const char* string, char* output)
{
- static char buf[MAP_NAME_LENGTH_EXT];
+ char buf[MAP_NAME_LENGTH_EXT];
char* dest = (output != NULL) ? output : buf;
-
- size_t len = safestrnlen(string, MAP_NAME_LENGTH);
+
+ size_t len;
+
+ strcpy(buf,string);
+ sscanf(string,"%*[^#]%*[#]%s",buf);
+
+ len = safestrnlen(buf, MAP_NAME_LENGTH);
+
if (len == MAP_NAME_LENGTH) {
- ShowWarning("(mapindex_normalize_name) Map name '%*s' is too long!\n", 2*MAP_NAME_LENGTH, string);
+ ShowWarning("(mapindex_normalize_name) Map name '%*s' is too long!", 2*MAP_NAME_LENGTH, buf);
len--;
}
-
- strncpy(dest, string, len+1);
-
+ strncpy(dest, buf, len+1);
+
if (len < 4 || stricmp(&dest[len-4], ".gat") != 0) {
strcpy(&dest[len], ".gat");
len += 4; // add .gat extension
@@ -70,10 +75,19 @@ const char* mapindex_getmapname_ext(const char* string, char* output)
/// Adds a map to the specified index
/// Returns 1 if successful, 0 oherwise
-static int mapindex_addmap(int index, const char* name)
+int mapindex_addmap(int index, const char* name)
{
char map_name[MAP_NAME_LENGTH];
+ if (index == -1){
+ for (index = 1; index < max_index; index++)
+ {
+ //if (strcmp(indexes[index].name,"#CLEARED#")==0)
+ if (indexes[index].name[0] == '\0')
+ break;
+ }
+ }
+
if (index < 0 || index >= MAX_MAPINDEX) {
ShowError("(mapindex_add) Map index (%d) for \"%s\" out of range (max is %d)\n", index, name, MAX_MAPINDEX);
return 0;
@@ -85,10 +99,11 @@ static int mapindex_addmap(int index, const char* name)
ShowError("(mapindex_add) Cannot add maps with no name.\n");
return 0;
}
- //if (strlen(map_name) >= MAP_NAME_LENGTH) {
- // ShowError("(mapindex_add) Map name %s is too long. Maps are limited to %d characters.\n", map_name, MAP_NAME_LENGTH);
- // return 0;
- //}
+
+ if (strlen(map_name) >= MAP_NAME_LENGTH) {
+ ShowError("(mapindex_add) Map name %s is too long. Maps are limited to %d characters.\n", map_name, MAP_NAME_LENGTH);
+ return 0;
+ }
if (mapindex_exists(index))
ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, indexes[index].name, map_name);
@@ -97,7 +112,7 @@ static int mapindex_addmap(int index, const char* name)
if (max_index <= index)
max_index = index+1;
- return 1;
+ return index;
}
unsigned short mapindex_name2id(const char* name)
@@ -170,6 +185,11 @@ void mapindex_init(void)
fclose(fp);
}
+int mapindex_removemap(int index){
+ indexes[index].name[0] = '\0';
+ return 0;
+}
+
void mapindex_final(void)
{
}
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index cd4c09d37..06131d0a4 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -47,4 +47,7 @@ const char* mapindex_id2name(unsigned short);
void mapindex_init(void);
void mapindex_final(void);
+int mapindex_addmap(int index, const char* name);
+int mapindex_removemap(int index);
+
#endif /* _MAPINDEX_H_ */
diff --git a/src/common/mmo.h b/src/common/mmo.h
index cb3f2b934..933893697 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -18,7 +18,7 @@
//The number is the max number of hotkeys to save (27 = 9 skills x 3 bars)
#define MAX_HOTKEYS 27
-#define MAX_MAP_PER_SERVER 1024
+#define MAX_MAP_PER_SERVER 1500 // Increased to allow creation of Instance Maps
#define MAX_INVENTORY 100
//Max number of characters per account. Note that changing this setting alone is not enough if the client is not hexed to support more characters as well.
#define MAX_CHARS 9