diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-02-03 00:15:55 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-02-03 01:19:57 +0100 |
commit | 3c4fee06100897f7e0ad91ea1468b4bdf0cdb56b (patch) | |
tree | 5a90c2060c95776f46d0a4ab87243ec49655f863 /crawl-ref/source/store.cc | |
parent | 536ad4b0897d82f1f824905eab219bf8174b7ec1 (diff) | |
download | crawl-ref-3c4fee06100897f7e0ad91ea1468b4bdf0cdb56b.tar.gz crawl-ref-3c4fee06100897f7e0ad91ea1468b4bdf0cdb56b.zip |
Add support for int64_t props.
Diffstat (limited to 'crawl-ref/source/store.cc')
-rw-r--r-- | crawl-ref/source/store.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc index 66a56463e0..1dbaf8cb4e 100644 --- a/crawl-ref/source/store.cc +++ b/crawl-ref/source/store.cc @@ -46,6 +46,7 @@ CrawlStoreValue::CrawlStoreValue(const CrawlStoreValue &other) case SV_BYTE: case SV_SHORT: case SV_INT: + case SV_INT64: case SV_FLOAT: val = other.val; break; @@ -165,6 +166,12 @@ CrawlStoreValue::CrawlStoreValue(const int &_val) get_int() = _val; } +CrawlStoreValue::CrawlStoreValue(const int64_t &_val) + : type(SV_INT), flags(SFLAG_UNSET) +{ + get_int64() = _val; +} + CrawlStoreValue::CrawlStoreValue(const float &_val) : type(SV_FLOAT), flags(SFLAG_UNSET) { @@ -274,6 +281,10 @@ void CrawlStoreValue::unset(bool force) val._int = 0; break; + case SV_INT64: + val._int64 = 0; + break; + case SV_FLOAT: val._float = 0.0; break; @@ -394,6 +405,7 @@ CrawlStoreValue &CrawlStoreValue::operator = (const CrawlStoreValue &other) case SV_BYTE: case SV_SHORT: case SV_INT: + case SV_INT64: case SV_FLOAT: val = other.val; break; @@ -486,6 +498,10 @@ void CrawlStoreValue::write(writer &th) const marshallInt(th, val._int); break; + case SV_INT64: + marshallSigned(th, val._int64); + break; + case SV_FLOAT: marshallFloat(th, val._float); break; @@ -587,6 +603,10 @@ void CrawlStoreValue::read(reader &th) val._int = unmarshallInt(th); break; + case SV_INT64: + val._int64 = unmarshallSigned(th); + break; + case SV_FLOAT: val._float = unmarshallFloat(th); break; @@ -746,6 +766,9 @@ CrawlVector &CrawlStoreValue::new_vector(store_val_type _type, case SV_INT: \ field = (_type) val._int; \ break; \ + case SV_INT64: \ + field = (_type) val._int64; \ + break; \ case SV_FLOAT: \ field = (_type) val._float; \ break; \ @@ -799,6 +822,11 @@ int &CrawlStoreValue::get_int() GET_VAL(SV_INT, int, val._int, 0); } +int64_t &CrawlStoreValue::get_int64() +{ + GET_VAL(SV_INT64, int64_t, val._int64, 0); +} + float &CrawlStoreValue::get_float() { GET_VAL(SV_FLOAT, float, val._float, 0.0); @@ -889,6 +917,12 @@ int CrawlStoreValue::get_int() const return val._int; } +int64_t CrawlStoreValue::get_int64() const +{ + GET_CONST_SETUP(SV_INT64); + return val._int64; +} + float CrawlStoreValue::get_float() const { GET_CONST_SETUP(SV_FLOAT); @@ -956,6 +990,7 @@ CrawlStoreValue::operator char&() { return get_byte(); } CrawlStoreValue::operator short&() { return get_short(); } CrawlStoreValue::operator float&() { return get_float(); } CrawlStoreValue::operator int&() { return get_int(); } +CrawlStoreValue::operator int64_t&() { return get_int64(); } CrawlStoreValue::operator std::string&() { return get_string(); } CrawlStoreValue::operator coord_def&() { return get_coord(); } CrawlStoreValue::operator CrawlHashTable&() { return get_table(); } @@ -1001,6 +1036,24 @@ CrawlStoreValue::operator int() const CONST_INT_CAST(); } +CrawlStoreValue::operator int64_t() const +{ + // Allow upgrading but not downgrading. + switch (type) + { + case SV_BYTE: + return get_byte(); + case SV_SHORT: + return get_short(); + case SV_INT: + return get_int(); + case SV_INT64: + return get_int64(); + default: + die("unknown stored value type"); + } +} + CrawlStoreValue::operator float() const { return get_float(); @@ -1052,6 +1105,12 @@ CrawlStoreValue &CrawlStoreValue::operator = (const int &_val) return (*this); } +CrawlStoreValue &CrawlStoreValue::operator = (const int64_t &_val) +{ + get_int64() = _val; + return (*this); +} + CrawlStoreValue &CrawlStoreValue::operator = (const float &_val) { get_float() = _val; @@ -1142,6 +1201,12 @@ CrawlStoreValue &CrawlStoreValue::operator = (const dlua_chunk &_val) temp op; \ return temp; \ } \ + case SV_INT64: \ + { \ + int64_t &temp = get_int64(); \ + temp op; \ + return temp; \ + } \ \ default: \ die("unknown stored value type"); \ |