diff options
author | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-08-14 14:03:53 +0000 |
---|---|---|
committer | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-08-14 14:03:53 +0000 |
commit | 174ade9a45988abf053cf45f30775fc6a76e706e (patch) | |
tree | a72ecf639a28e68b9a1affc2a9961cb80be191ed /src/map/instance.c | |
parent | e9f0392e73cdb07067bbd031aeb4bdeff131ae93 (diff) | |
download | hercules-174ade9a45988abf053cf45f30775fc6a76e706e.tar.gz hercules-174ade9a45988abf053cf45f30775fc6a76e706e.tar.bz2 hercules-174ade9a45988abf053cf45f30775fc6a76e706e.tar.xz hercules-174ade9a45988abf053cf45f30775fc6a76e706e.zip |
- Fixes and optimization to instancing. Thanks to Saithis
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14006 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/instance.c')
-rw-r--r-- | src/map/instance.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/map/instance.c b/src/map/instance.c index 45e610b8d..c617e60c4 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -75,7 +75,7 @@ int instance_create(int party_id, const char *name) /*--------------------------------------
* Add a map to the instance using src map "name"
*--------------------------------------*/
-int instance_add_map(const char *name, int instance_id)
+int instance_add_map(const char *name, int instance_id, bool usebasename)
{
int m = map_mapname2mapid(name), i, im = -1;
size_t num_cell, size;
@@ -109,7 +109,7 @@ int instance_add_map(const char *name, int instance_id) else im = map_num++; // Using next map index
memcpy( &map[im], &map[m], sizeof(struct map_data) ); // Copy source map
- snprintf(map[im].name, MAP_NAME_LENGTH, "%.3d%s", instance_id, name); // Generate Name for Instance Map
+ snprintf(map[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map
map[im].index = mapindex_addmap(-1, map[im].name); // Add map index
if( !map[im].index )
@@ -150,24 +150,15 @@ int instance_add_map(const char *name, int instance_id) * party_id : source party of this instance
* type : result (0 = map id | 1 = instance id)
*--------------------------------------*/
-int instance_map2imap(int m, int party_id, int type)
+int instance_map2imap(int m, int instance_id)
{
- int i;
- struct party_data *p;
- if( (p = party_search(party_id)) == NULL || !p->instance_id )
- return -1;
-
- for( i = 0; i < instance[p->instance_id].num_map; i++ )
- {
- if( instance[p->instance_id].map[i] && map[instance[p->instance_id].map[i]].instance_src_map == m )
- {
- if( type == 0 )
- return instance[p->instance_id].map[i];
- else
- return p->instance_id;
- }
- }
- return -1;
+ int i;
+ for( i = 0; i < instance[instance_id].num_map; i++ )
+ {
+ if( instance[instance_id].map[i] && map[instance[instance_id].map[i]].instance_src_map == m )
+ return instance[instance_id].map[i];
+ }
+ return -1;
}
/*--------------------------------------
|