--- deliantra/server/common/map.C 2009/10/15 21:40:42 1.163 +++ deliantra/server/common/map.C 2009/10/21 00:44:39 1.166 @@ -82,9 +82,6 @@ return 1; } - /* Save some cycles - instead of calling get_map_flags(), just get the value - * directly. - */ mapspace &ms = m->at (sx, sy); int mflags = ms.flags (); @@ -116,51 +113,45 @@ */ for (object *tmp = ms.bot; tmp; tmp = tmp->above) { - bool block = OB_MOVE_BLOCK (ob, tmp); - - /* This must be before the checks below. Code for inventory checkers. */ - if (block && tmp->type == CHECK_INV) + if (OB_MOVE_BLOCK (ob, tmp)) { - bool have = check_inv_recursive (ob, tmp); + if (INVOKE_OBJECT (BLOCKED_MOVE, tmp, ob)) + if (RESULT_INT (0)) + return 1; + else + continue; - /* If last_sp is set, the player/monster needs an object, - * so we check for it. If they don't have it, they can't - * pass through this space. - */ - if (tmp->last_sp) + if (tmp->type == CHECK_INV) { - if (!have) + bool have = check_inv_recursive (ob, tmp); + + // last_sp set means we block if we don't have. + if (logical_xor (have, tmp->last_sp)) return 1; } - else + else if (tmp->type == T_MATCH) { - /* In this case, the player must not have the object - - * if they do, they can't pass through. - */ - if (have) + // T_MATCH allows "entrance" iff the match is true + // == blocks if the match fails + + // we could have used an INVOKE_OBJECT, but decided against it, as we + // assume that T_MATCH is relatively common. + if (!match (tmp->slaying, ob, tmp, ob)) return 1; } - } - else if (block && tmp->type == T_MATCH) - { - //TODO - } - else - { - /* Broke apart a big nasty if into several here to make - * this more readable. first check - if the space blocks - * movement, can't move here. - * second - if a monster, can't move there, unless it is a - * dm. - */ - if (block) - return 1; + else + return 1; // unconditional block + + } else { + // space does not block the ob, directly, but + // anything alive that is not a door still + // blocks anything but wizards. if (tmp->flag [FLAG_ALIVE] && tmp->head_ () != ob && tmp != ob && tmp->type != DOOR - && !tmp->flag [FLAG_WIZ]) + && !tmp->flag [FLAG_WIZPASS]) return 1; } } @@ -568,32 +559,30 @@ /* opposite of parse string, this puts the string that was originally fed in to * the map (or something equivilent) into output_string. */ -static void -print_shop_string (maptile *m, char *output_string) +static const char * +print_shop_string (maptile *m) { - int i; - char tmp[MAX_BUF]; + static dynbuf_text buf; buf.clear (); - strcpy (output_string, ""); - for (i = 0; i < m->shopitems[0].index; i++) + for (int i = 0; i < m->shopitems[0].index; i++) { if (m->shopitems[i].typenum) { if (m->shopitems[i].strength) - sprintf (tmp, "%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); + buf.printf ("%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); else - sprintf (tmp, "%s;", m->shopitems[i].name); + buf.printf ("%s;", m->shopitems[i].name); } else { if (m->shopitems[i].strength) - sprintf (tmp, "*:%d;", m->shopitems[i].strength); + buf.printf ("*:%d;", m->shopitems[i].strength); else - sprintf (tmp, "*"); + buf.printf ("*"); } - - strcat (output_string, tmp); } + + return buf; } /* This loads the header information of the map. The header @@ -738,20 +727,14 @@ MAP_OUT (no_reset); MAP_OUT (no_drop); MAP_OUT (difficulty); - if (default_region) MAP_OUT2 (region, default_region->name); - if (shopitems) - { - char shop[MAX_BUF]; - print_shop_string (this, shop); - MAP_OUT2 (shopitems, shop); - } - + if (shopitems) MAP_OUT2 (shopitems, print_shop_string (this)); MAP_OUT (shopgreed); MAP_OUT (shopmin); MAP_OUT (shopmax); if (shoprace) MAP_OUT (shoprace); + MAP_OUT (darkness); MAP_OUT (width); MAP_OUT (height);