From 0cb37ef9c9aa55e1a24816666080b54b554843cb Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 17 Jan 2007 08:03:38 +0000 Subject: The stash-tracker also needs shop SIGHUP protection. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@859 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/shopping.cc | 21 --------------------- crawl-ref/source/shopping.h | 22 ++++++++++++++++++++++ crawl-ref/source/stash.cc | 3 ++- crawl-ref/source/stash.h | 3 ++- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 8f41ed4fce..143c36c0d9 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -1612,27 +1612,6 @@ unsigned int item_value( item_def item, id_arr id, bool ident ) return (valued); } // end item_value() -// Protect the id array against being clobbered by a SIGHUP with the -// character in a shop. -extern id_arr shop_backup_id; -class shopping_hup_protect -{ -public: - shopping_hup_protect() : shopping(crawl_state.shopping) - { - save_id(shop_backup_id); - crawl_state.shopping = true; - } - - ~shopping_hup_protect() - { - crawl_state.shopping = shopping; - } - -private: - bool shopping; -}; - void shop(void) { unsigned char i = 0; diff --git a/crawl-ref/source/shopping.h b/crawl-ref/source/shopping.h index fd33af98f5..39e9c48a4c 100644 --- a/crawl-ref/source/shopping.h +++ b/crawl-ref/source/shopping.h @@ -15,6 +15,7 @@ #define SHOPPING_H #include "externs.h" +#include "itemname.h" void shop_init_id_type(int shoptype, id_fix_arr &shop_id); void shop_uninit_id_type(int shoptype, const id_fix_arr &shop_id); @@ -45,4 +46,25 @@ const shop_struct *get_shop(int sx, int sy); * *********************************************************************** */ const char *shop_name(int sx, int sy); +// Protect the id array against being clobbered by a SIGHUP with the +// character in a shop. +extern id_arr shop_backup_id; +class shopping_hup_protect +{ +public: + shopping_hup_protect() : shopping(crawl_state.shopping) + { + save_id(shop_backup_id); + crawl_state.shopping = true; + } + + ~shopping_hup_protect() + { + crawl_state.shopping = shopping; + } + +private: + bool shopping; +}; + #endif diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 2a2f43b0f0..890d6a141c 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -627,7 +627,8 @@ ShopInfo::ShopInfo(int xp, int yp) : x(xp), y(yp), name(), shoptype(-1), shoptype = sh->type; } -ShopInfo::ShopId::ShopId(int stype) : shoptype(stype), id() +ShopInfo::ShopId::ShopId(int stype) + : shopping_hup_protect(), shoptype(stype), id() { shop_init_id_type( shoptype, id ); } diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h index bb71a4695b..5575b04ce0 100644 --- a/crawl-ref/source/stash.h +++ b/crawl-ref/source/stash.h @@ -149,7 +149,8 @@ private: std::string shop_item_desc(const shop_item &si) const; void describe_shop_item(const shop_item &si) const; - class ShopId { + class ShopId : public shopping_hup_protect + { public: ShopId(int stype); ~ShopId(); -- cgit v1.2.3-54-g00ecf