diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2012-12-12 22:40:37 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2012-12-12 22:43:10 -0800 |
commit | f9563edf69f083287630f4b17db70d97524196d6 (patch) | |
tree | 495a75932bf493c4a2afb94f924e3efde4ea70a8 /src/tool/moneycount | |
parent | 608f959900968e83fd25231c72308fc608742dd5 (diff) | |
download | tmwa-f9563edf69f083287630f4b17db70d97524196d6.tar.gz tmwa-f9563edf69f083287630f4b17db70d97524196d6.tar.bz2 tmwa-f9563edf69f083287630f4b17db70d97524196d6.tar.xz tmwa-f9563edf69f083287630f4b17db70d97524196d6.zip |
Delete old tools
If there was anything you actually used, tell me.
Diffstat (limited to 'src/tool/moneycount')
-rw-r--r-- | src/tool/moneycount/athena_text.cpp | 263 | ||||
-rw-r--r-- | src/tool/moneycount/athena_text.hpp | 9 | ||||
-rw-r--r-- | src/tool/moneycount/inf.cpp | 1482 | ||||
-rw-r--r-- | src/tool/moneycount/inf.hpp | 228 | ||||
-rw-r--r-- | src/tool/moneycount/main.cpp | 180 | ||||
-rw-r--r-- | src/tool/moneycount/mmo.hpp | 309 | ||||
-rw-r--r-- | src/tool/moneycount/portability_exceptions.hpp | 33 | ||||
-rw-r--r-- | src/tool/moneycount/portability_fixes.cpp | 39 | ||||
-rw-r--r-- | src/tool/moneycount/portability_fixes.hpp | 127 |
9 files changed, 0 insertions, 2670 deletions
diff --git a/src/tool/moneycount/athena_text.cpp b/src/tool/moneycount/athena_text.cpp deleted file mode 100644 index 8cf5457..0000000 --- a/src/tool/moneycount/athena_text.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "athena_text.hpp" - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "mmo.hpp" - -//------------------------------------------------------------------------- -// Function to set the character from the line (at read of characters file) -//------------------------------------------------------------------------- -int mmo_char_fromstr (char *str, struct mmo_charstatus *p) -{ - int tmp_int[256]; - int set, next, len, i; - - // initilialise character - memset (p, '\0', sizeof (struct mmo_charstatus)); - - // If it's not char structure of version 1008 and after - if ((set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, // - &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], p->last_point.map, &tmp_int[35], &tmp_int[36], // - p->save_point.map, &tmp_int[37], &tmp_int[38], - &tmp_int[39], &next)) != 43) - { - tmp_int[39] = 0; // partner id - // If not char structure from version 384 to 1007 - if ((set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, // - &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], p->last_point.map, &tmp_int[35], &tmp_int[36], // - p->save_point.map, &tmp_int[37], &tmp_int[38], - &next)) != 42) - { - // It's char structure of a version before 384 - tmp_int[26] = 0; // pet id - set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, // - &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], // - &tmp_int[24], &tmp_int[25], // - &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], p->last_point.map, &tmp_int[35], &tmp_int[36], // - p->save_point.map, &tmp_int[37], &tmp_int[38], - &next); - set += 2; - //printf("char: old char data ver.1\n"); - // Char structure of version 1007 or older - } - else - { - set++; - //printf("char: old char data ver.2\n"); - } - // Char structure of version 1008+ - } - else - { - //printf("char: new char data ver.3\n"); - } - if (set != 43) - return 0; - - p->char_id = tmp_int[0]; - p->account_id = tmp_int[1]; - p->char_num = tmp_int[2]; - p->classb = tmp_int[3]; - p->base_level = tmp_int[4]; - p->job_level = tmp_int[5]; - p->base_exp = tmp_int[6]; - p->job_exp = tmp_int[7]; - p->zeny = tmp_int[8]; - p->hp = tmp_int[9]; - p->max_hp = tmp_int[10]; - p->sp = tmp_int[11]; - p->max_sp = tmp_int[12]; - p->str = tmp_int[13]; - p->agi = tmp_int[14]; - p->vit = tmp_int[15]; - p->int_ = tmp_int[16]; - p->dex = tmp_int[17]; - p->luk = tmp_int[18]; - p->status_point = tmp_int[19]; - p->skill_point = tmp_int[20]; - p->option = tmp_int[21]; - p->karma = tmp_int[22]; - p->manner = tmp_int[23]; - p->party_id = tmp_int[24]; - p->guild_id = tmp_int[25]; -// p->pet_id = tmp_int[26]; - p->hair = tmp_int[27]; - p->hair_color = tmp_int[28]; - p->clothes_color = tmp_int[29]; - p->weapon = tmp_int[30]; - p->shield = tmp_int[31]; - p->head_top = tmp_int[32]; - p->head_mid = tmp_int[33]; - p->head_bottom = tmp_int[34]; - p->last_point.x = tmp_int[35]; - p->last_point.y = tmp_int[36]; - p->save_point.x = tmp_int[37]; - p->save_point.y = tmp_int[38]; - p->partner_id = tmp_int[39]; - - if (str[next] == '\n' || str[next] == '\r') - return 1; // ?V?K?f?[?^ - - next++; - - for (i = 0; str[next] && str[next] != '\t'; i++) - { - if (sscanf - (str + next, "%[^,],%d,%d%n", p->memo_point[i].map, &tmp_int[0], - &tmp_int[1], &len) != 3) - return -3; - p->memo_point[i].x = tmp_int[0]; - p->memo_point[i].y = tmp_int[1]; - next += len; - if (str[next] == ' ') - next++; - } - - next++; - - for (i = 0; str[next] && str[next] != '\t'; i++) - { - if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], - &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], - &tmp_int[11], &len) == 12) - { - // do nothing, it's ok - } - else if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], - &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], - &len) == 11) - { - tmp_int[11] = 0; // broken doesn't exist in this version -> 0 - } - else // invalid structure - return -4; - p->inventory[i].id = tmp_int[0]; - p->inventory[i].nameid = tmp_int[1]; - p->inventory[i].amount = tmp_int[2]; - p->inventory[i].equip = tmp_int[3]; - p->inventory[i].identify = tmp_int[4]; - p->inventory[i].refine = tmp_int[5]; - p->inventory[i].attribute = tmp_int[6]; - p->inventory[i].card[0] = tmp_int[7]; - p->inventory[i].card[1] = tmp_int[8]; - p->inventory[i].card[2] = tmp_int[9]; - p->inventory[i].card[3] = tmp_int[10]; - p->inventory[i].broken = tmp_int[11]; - next += len; - if (str[next] == ' ') - next++; - } - - next++; - - for (i = 0; str[next] && str[next] != '\t'; i++) - { - if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], - &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], - &tmp_int[11], &len) == 12) - { - // do nothing, it's ok - } - else if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], - &tmp_int[4], &tmp_int[5], &tmp_int[6], - &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], - &len) == 11) - { - tmp_int[11] = 0; // broken doesn't exist in this version -> 0 - } - else // invalid structure - return -5; - p->cart[i].id = tmp_int[0]; - p->cart[i].nameid = tmp_int[1]; - p->cart[i].amount = tmp_int[2]; - p->cart[i].equip = tmp_int[3]; - p->cart[i].identify = tmp_int[4]; - p->cart[i].refine = tmp_int[5]; - p->cart[i].attribute = tmp_int[6]; - p->cart[i].card[0] = tmp_int[7]; - p->cart[i].card[1] = tmp_int[8]; - p->cart[i].card[2] = tmp_int[9]; - p->cart[i].card[3] = tmp_int[10]; - p->cart[i].broken = tmp_int[11]; - next += len; - if (str[next] == ' ') - next++; - } - - next++; - - for (i = 0; str[next] && str[next] != '\t'; i++) - { - if (sscanf (str + next, "%d,%d%n", &tmp_int[0], &tmp_int[1], &len) != - 2) - return -6; - p->skill[tmp_int[0]].id = tmp_int[0]; - p->skill[tmp_int[0]].lv = tmp_int[1] & 0xffff; - p->skill[tmp_int[0]].flags = ((tmp_int[1] >> 16) & 0xffff); - next += len; - if (str[next] == ' ') - next++; - } - - next++; - - for (i = 0; - str[next] && str[next] != '\t' && str[next] != '\n' - && str[next] != '\r'; i++) - { // global_reg?????O??athena.txt????^????'\n'?`?F?b?N - if (sscanf - (str + next, "%[^,],%d%n", p->global_reg[i].str, - &p->global_reg[i].value, &len) != 2) - { - // because some scripts are not correct, the str can be "". So, we must check that. - // If it's, we must not refuse the character, but just this REG value. - // Character line will have something like: nov_2nd_cos,9 ,9 nov_1_2_cos_c,1 (here, ,9 is not good) - if (str[next] == ',' - && sscanf (str + next, ",%d%n", &p->global_reg[i].value, - &len) == 1) - i--; - else - return -7; - } - next += len; - if (str[next] == ' ') - next++; - } - p->global_reg_num = i; - - return 1; -} - -int accreg_fromstr (char *str, struct accreg *reg) -{ - int j, v, n; - char buf[128]; - const char *p = str; - - if (sscanf (p, "%d\t%n", ®->account_id, &n) != 1 - || reg->account_id <= 0) - return 0; - - for (j = 0, p += n; j < ACCOUNT_REG_NUM; j++, p += n) - { - if (sscanf (p, "%[^,],%d %n", buf, &v, &n) != 2) - break; - memcpy (reg->reg[j].str, buf, 32); - reg->reg[j].value = v; - } - reg->reg_num = j; - - return 1; -} - diff --git a/src/tool/moneycount/athena_text.hpp b/src/tool/moneycount/athena_text.hpp deleted file mode 100644 index e4b7025..0000000 --- a/src/tool/moneycount/athena_text.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef ATHENA_TEXT_HPP -#define ATHENA_TEXT_HPP -#include "mmo.hpp" - -int mmo_char_fromstr (char *str, struct mmo_charstatus *p); - -int accreg_fromstr (char *str, struct accreg *reg); - -#endif diff --git a/src/tool/moneycount/inf.cpp b/src/tool/moneycount/inf.cpp deleted file mode 100644 index 80b0475..0000000 --- a/src/tool/moneycount/inf.cpp +++ /dev/null @@ -1,1482 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// The integer is represented as a sequence of bytes. They are stored such that
-// element 0 is the lsB, which makes sense when seen as an integer offset but
-// is counter-intuitive when you think that a string is usually read from left
-// to right, 0 to size-1, in which case the lsB is on the *left*.
-
-// This solution is compatible with 32-bit and 64-bit machines with either
-// little-endian or big-endian representations of integers.
-
-// Problem: I'm using std::string, which is an array of char. However, char is
-// not well-defined - it could be signed or unsigned.
-
-// In fact, there's no requirement for a char to even be one byte - it can be
-// any size of one byte or more. However, it's just impossible to make any
-// progress with that naffness (thanks to the C non-standardisation committee)
-// and the practice is that char on every platform/compiler I've ever come
-// across is that char = byte.
-
-// The algorithms here use unsigned char to represent bit-patterns so I have to
-// be careful to type-cast from char to unsigned char a lot. I use a typedef to
-// make life easier.
-
-////////////////////////////////////////////////////////////////////////////////
-#include "inf.hpp"
-#include <ctype.h>
-////////////////////////////////////////////////////////////////////////////////
-
-namespace stlplus
-{
-
- ////////////////////////////////////////////////////////////////////////////////
- // choose a sensible C type for a byte
-
- typedef unsigned char byte;
-
- ////////////////////////////////////////////////////////////////////////////////
- // local functions
-
- // removes leading bytes that don't contribute to the value to create the minimum string representation
- static void reduce_string(std::string& data)
- {
- while(data.size() > 1 &&
- ((byte(data[data.size()-1]) == byte(0) && byte(data[data.size()-2]) < byte(128)) ||
- (byte(data[data.size()-1]) == byte(255) && byte(data[data.size()-2]) >= byte(128))))
- {
- data.erase(data.end()-1);
- }
- }
-
- // generic implementations of type conversions from integer type to internal representation
- // data: integer value for conversion
- // result: internal representation
-
- template <typename T>
- static void convert_from_signed(const T& data, std::string& result)
- {
- result.erase();
- bool lsb_first = little_endian();
- byte* address = (byte*)&data;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = (lsb_first ? i : (sizeof(T) - i - 1));
- result.append(1,address[offset]);
- }
- reduce_string(result);
- }
-
- template <typename T>
- static void convert_from_unsigned(const T& data, std::string& result)
- {
- result.erase();
- bool lsb_first = little_endian();
- byte* address = (byte*)&data;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = (lsb_first ? i : (sizeof(T) - i - 1));
- result.append(1,address[offset]);
- }
- // inf is signed - so there is a possible extra sign bit to add
- result.append(1,std::string::value_type(0));
- reduce_string(result);
- }
-
- // generic implementations of type conversions from internal representation to an integer type
- // data : string representation of integer
- // result: integer result of conversion
- // return: flag indicating success - false = overflow
-
- template <class T>
- bool convert_to_signed(const std::string& data, T& result)
- {
- bool lsb_first = little_endian();
- byte* address = (byte*)&result;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = lsb_first ? i : (sizeof(T) - i - 1);
- if (i < data.size())
- address[offset] = byte(data[i]);
- else if (data.empty() || (byte(data[data.size()-1]) < byte(128)))
- address[offset] = byte(0);
- else
- address[offset] = byte(255);
- }
- return data.size() <= sizeof(T);
- }
-
- template <class T>
- bool convert_to_unsigned(const std::string& data, T& result)
- {
- bool lsb_first = little_endian();
- byte* address = (byte*)&result;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = lsb_first ? i : (sizeof(T) - i - 1);
- if (i < data.size())
- address[offset] = byte(data[i]);
- else
- address[offset] = byte(0);
- }
- return data.size() <= sizeof(T);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // Conversions to string
-
- static char to_char [] = "0123456789abcdefghijklmnopqrstuvwxyz";
- static int from_char [] =
- {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
- };
-
- static void convert_to_string(const stlplus::inf& data, std::string& result, unsigned radix = 10)
- throw(std::invalid_argument)
- {
- // only support the C-style radixes plus 0b for binary
- if (radix != 2 && radix != 8 && radix != 10 && radix != 16)
- throw std::invalid_argument("invalid radix value");
- inf local_i = data;
- // untangle all the options
- bool binary = radix == 2;
- bool octal = radix == 8;
- bool hex = radix == 16;
- // the C representations for binary, octal and hex use 2's-complement representation
- // all other represenations use sign-magnitude
- if (hex || octal || binary)
- {
- // bit-pattern representation
- // this is the binary representation optionally shown in octal or hex
- // first generate the binary by masking the bits
- for (unsigned j = local_i.bits(); j--; )
- result += (local_i.bit(j) ? '1' : '0');
- // the result is now the full width of the type - e.g. int will give a 32-bit result
- // now interpret this as either binary, octal or hex and add the prefix
- if (binary)
- {
- // trim down to the smallest string that preserves the value
- while (true)
- {
- // do not trim to less than 1 bit (sign only)
- if (result.size() <= 1) break;
- // only trim if it doesn't change the sign and therefore the value
- if (result[0] != result[1]) break;
- result.erase(0,1);
- }
- // add the prefix
- result.insert((std::string::size_type)0, "0b");
- }
- else if (octal)
- {
- // the result is currently binary
- // trim down to the smallest string that preserves the value
- while (true)
- {
- // do not trim to less than 2 bits (sign plus 1-bit magnitude)
- if (result.size() <= 2) break;
- // only trim if it doesn't change the sign and therefore the value
- if (result[0] != result[1]) break;
- result.erase(0,1);
- }
- // also ensure that the binary is a multiple of 3 bits to make the conversion to octal easier
- while (result.size() % 3 != 0)
- result.insert((std::string::size_type)0, 1, result[0]);
- // now convert to octal
- std::string octal_result;
- for (unsigned i = 0; i < result.size()/3; i++)
- {
- // yuck - ugly or what?
- if (result[i*3] == '0')
- {
- if (result[i*3+1] == '0')
- {
- if (result[i*3+2] == '0')
- octal_result += '0';
- else
- octal_result += '1';
- }
- else
- {
- if (result[i*3+2] == '0')
- octal_result += '2';
- else
- octal_result += '3';
- }
- }
- else
- {
- if (result[i*3+1] == '0')
- {
- if (result[i*3+2] == '0')
- octal_result += '4';
- else
- octal_result += '5';
- }
- else
- {
- if (result[i*3+2] == '0')
- octal_result += '6';
- else
- octal_result += '7';
- }
- }
- }
- result = octal_result;
- // add the prefix
- result.insert((std::string::size_type)0, "0");
- }
- else
- {
- // similar to octal
- while (true)
- {
- // do not trim to less than 2 bits (sign plus 1-bit magnitude)
- if (result.size() <= 2) break;
- // only trim if it doesn't change the sign and therefore the value
- if (result[0] != result[1]) break;
- result.erase(0,1);
- }
- // pad to a multiple of 4 characters
- while (result.size() % 4 != 0)
- result.insert((std::string::size_type)0, 1, result[0]);
- // now convert to hex
- std::string hex_result;
- for (unsigned i = 0; i < result.size()/4; i++)
- {
- // yuck - ugly or what?
- if (result[i*4] == '0')
- {
- if (result[i*4+1] == '0')
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += '0';
- else
- hex_result += '1';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += '2';
- else
- hex_result += '3';
- }
- }
- else
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += '4';
- else
- hex_result += '5';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += '6';
- else
- hex_result += '7';
- }
- }
- }
- else
- {
- if (result[i*4+1] == '0')
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += '8';
- else
- hex_result += '9';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += 'a';
- else
- hex_result += 'b';
- }
- }
- else
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += 'c';
- else
- hex_result += 'd';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += 'e';
- else
- hex_result += 'f';
- }
- }
- }
- }
- result = hex_result;
- // add the prefix
- result.insert((std::string::size_type)0, "0x");
- }
- }
- else
- {
- // convert to sign-magnitude
- // the representation is:
- // [sign]magnitude
- bool negative = local_i.negative();
- local_i.abs();
- // create a representation of the magnitude by successive division
- inf inf_radix(radix);
- do
- {
- std::pair<inf,inf> divided = local_i.divide(inf_radix);
- unsigned remainder = divided.second.to_unsigned();
- char digit = to_char[remainder];
- result.insert((std::string::size_type)0, 1, digit);
- local_i = divided.first;
- }
- while(!local_i.zero());
- // add the prefixes
- // add a sign only for negative values
- if (negative)
- result.insert((std::string::size_type)0, 1, '-');
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // Conversions FROM string
-
- void convert_from_string(const std::string& str, inf& result, unsigned radix = 10) throw(std::invalid_argument)
- {
- result = 0;
- // only support the C-style radixes plus 0b for binary
- // a radix of 0 means deduce the radix from the input - assume 10
- if (radix != 0 && radix != 2 && radix != 8 && radix != 10 && radix != 16)
- throw std::invalid_argument("invalid radix value");
- unsigned i = 0;
- // the radix passed as a parameter is just the default - it can be
- // overridden by the C prefix
- // Note: a leading zero is the C-style prefix for octal - I only make this
- // override the default when the default radix is not specified
- // first check for a C-style prefix
- bool c_style = false;
- if (i < str.size() && str[i] == '0')
- {
- // binary or hex
- if (i+1 < str.size() && tolower(str[i+1]) == 'x')
- {
- c_style = true;
- radix = 16;
- i += 2;
- }
- else if (i+1 < str.size() && tolower(str[i+1]) == 'b')
- {
- c_style = true;
- radix = 2;
- i += 2;
- }
- else if (radix == 0)
- {
- c_style = true;
- radix = 8;
- i += 1;
- }
- }
- if (radix == 0)
- radix = 10;
- if (c_style)
- {
- // the C style formats are bit patterns not integer values - these need
- // to be sign-extended to get the right value
- std::string binary;
- if (radix == 2)
- {
- for (unsigned j = i; j < str.size(); j++)
- {
- switch(str[j])
- {
- case '0':
- binary += '0';
- break;
- case '1':
- binary += '1';
- break;
- default:
- throw std::invalid_argument("invalid binary character in string " + str);
- }
- }
- }
- else if (radix == 8)
- {
- for (unsigned j = i; j < str.size(); j++)
- {
- switch(str[j])
- {
- case '0':
- binary += "000";
- break;
- case '1':
- binary += "001";
- break;
- case '2':
- binary += "010";
- break;
- case '3':
- binary += "011";
- break;
- case '4':
- binary += "100";
- break;
- case '5':
- binary += "101";
- break;
- case '6':
- binary += "110";
- break;
- case '7':
- binary += "111";
- break;
- default:
- throw std::invalid_argument("invalid octal character in string " + str);
- }
- }
- }
- else
- {
- for (unsigned j = i; j < str.size(); j++)
- {
- switch(tolower(str[j]))
- {
- case '0':
- binary += "0000";
- break;
- case '1':
- binary += "0001";
- break;
- case '2':
- binary += "0010";
- break;
- case '3':
- binary += "0011";
- break;
- case '4':
- binary += "0100";
- break;
- case '5':
- binary += "0101";
- break;
- case '6':
- binary += "0110";
- break;
- case '7':
- binary += "0111";
- break;
- case '8':
- binary += "1000";
- break;
- case '9':
- binary += "1001";
- break;
- case 'a':
- binary += "1010";
- break;
- case 'b':
- binary += "1011";
- break;
- case 'c':
- binary += "1100";
- break;
- case 'd':
- binary += "1101";
- break;
- case 'e':
- binary += "1110";
- break;
- case 'f':
- binary += "1111";
- break;
- default:
- throw std::invalid_argument("invalid hex character in string " + str);
- }
- }
- }
- // now convert the value
- result.resize(binary.size());
- for (unsigned j = 0; j < binary.size(); j++)
- result.preset(binary.size() - j - 1, binary[j] == '1');
- }
- else
- {
- // sign-magnitude representation
- // now scan for a sign and find whether this is a negative number
- bool negative = false;
- if (i < str.size())
- {
- switch (str[i])
- {
- case '-':
- negative = true;
- i++;
- break;
- case '+':
- i++;
- break;
- }
- }
- for (; i < str.size(); i++)
- {
- result *= inf(radix);
- unsigned char ascii = (unsigned char)str[i];
- int ch = from_char[ascii] ;
- if (ch == -1)
- throw std::invalid_argument("invalid decimal character in string " + str);
- result += inf(ch);
- }
- if (negative)
- result.negate();
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // constructors - mostly implemented in terms of the assignment operators
-
- inf::inf(void)
- {
- // void constructor initialises to zero - represented as a single-byte value containing zero
- m_data.append(1,std::string::value_type(0));
- }
-
- inf::inf(short r)
- {
- operator=(r);
- }
-
- inf::inf(unsigned short r)
- {
- operator=(r);
- }
-
- inf::inf(int r)
- {
- operator=(r);
- }
-
- inf::inf(unsigned r)
- {
- operator=(r);
- }
-
- inf::inf(long r)
- {
- operator=(r);
- }
-
- inf::inf(unsigned long r)
- {
- operator=(r);
- }
-
- inf::inf (const std::string& r) throw(std::invalid_argument)
- {
- operator=(r);
- }
-
- inf::inf(const inf& r)
- {
-#ifdef __BORLANDC__
- // work round bug in Borland compiler - copy constructor fails if string
- // contains null characters, so do my own copy
- for (unsigned i = 0; i < r.m_data.size(); i++)
- m_data += r.m_data[i];
-#else
- m_data = r.m_data;
-#endif
- }
-
- ////////////////////////////////////////////////////////////////////////////////
-
- inf::~inf(void)
- {
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // assignments convert from iteger types to internal representation
-
- inf& inf::operator = (short r)
- {
- convert_from_signed(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (unsigned short r)
- {
- convert_from_unsigned(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (int r)
- {
- convert_from_signed(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (unsigned r)
- {
- convert_from_unsigned(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (long r)
- {
- convert_from_signed(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (unsigned long r)
- {
- convert_from_unsigned(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (const std::string& r) throw(std::invalid_argument)
- {
- convert_from_string(r, *this);
- return *this;
- }
-
- inf& inf::operator = (const inf& r)
- {
- m_data = r.m_data;
- return *this;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
-
- short inf::to_short(bool truncate) const throw(std::overflow_error)
- {
- short result = 0;
- if (!convert_to_signed(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_short");
- return result;
- }
-
- unsigned short inf::to_unsigned_short(bool truncate) const throw(std::overflow_error)
- {
- unsigned short result = 0;
- if (!convert_to_unsigned(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_unsigned_short");
- return result;
- }
-
- int inf::to_int(bool truncate) const throw(std::overflow_error)
- {
- int result = 0;
- if (!convert_to_signed(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_int");
- return result;
- }
-
- unsigned inf::to_unsigned(bool truncate) const throw(std::overflow_error)
- {
- unsigned result = 0;
- if (!convert_to_unsigned(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_unsigned");
- return result;
- }
-
- long inf::to_long(bool truncate) const throw(std::overflow_error)
- {
- long result = 0;
- if (!convert_to_signed(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_long");
- return result;
- }
-
- unsigned long inf::to_unsigned_long(bool truncate) const throw(std::overflow_error)
- {
- unsigned long result = 0;
- if (!convert_to_unsigned(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_unsigned_long");
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // resize the inf regardless of the data
-
- void inf::resize(unsigned bits)
- {
- if (bits == 0) bits = 1;
- unsigned bytes = (bits+7)/8;
- byte extend = negative() ? byte(255) : byte (0);
- while(bytes > m_data.size())
- m_data.append(1,extend);
- }
-
- // reduce the bit count to the minimum needed to preserve the value
-
- void inf::reduce(void)
- {
- reduce_string(m_data);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // the number of significant bits in the number
-
- unsigned inf::bits (void) const
- {
- // The number of significant bits in the integer value - this is the number
- // of indexable bits less any redundant sign bits at the msb
- // This does not assume that the inf has been reduced to its minimum form
- unsigned result = indexable_bits();
- bool sign = bit(result-1);
- while (result > 1 && (sign == bit(result-2)))
- result--;
- return result;
- }
-
- unsigned inf::size(void) const
- {
- return bits();
- }
-
- unsigned inf::indexable_bits (void) const
- {
- return 8 * unsigned(m_data.size());
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // bitwise operations
-
- bool inf::bit (unsigned index) const throw(std::out_of_range)
- {
- if (index >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::bit"));
- // first split the offset into byte offset and bit offset
- unsigned byte_offset = index/8;
- unsigned bit_offset = index%8;
- return (byte(m_data[byte_offset]) & (byte(1) << bit_offset)) != 0;
- }
-
- bool inf::operator [] (unsigned index) const throw(std::out_of_range)
- {
- return bit(index);
- }
-
- void inf::set (unsigned index) throw(std::out_of_range)
- {
- if (index >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::set"));
- // first split the offset into byte offset and bit offset
- unsigned byte_offset = index/8;
- unsigned bit_offset = index%8;
- m_data[byte_offset] |= (byte(1) << bit_offset);
- }
-
- void inf::clear (unsigned index) throw(std::out_of_range)
- {
- if (index >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::clear"));
- // first split the offset into byte offset and bit offset
- unsigned byte_offset = index/8;
- unsigned bit_offset = index%8;
- m_data[byte_offset] &= (~(byte(1) << bit_offset));
- }
-
- void inf::preset (unsigned index, bool value) throw(std::out_of_range)
- {
- if (value)
- set(index);
- else
- clear(index);
- }
-
- inf inf::slice(unsigned low, unsigned high) const throw(std::out_of_range)
- {
- if (low >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::slice: low index"));
- if (high >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::slice: high index"));
- inf result;
- if (high >= low)
- {
- // create a result the right size and filled with sign bits
- std::string::size_type result_size = (high-low+1+7)/8;
- result.m_data.erase();
- byte extend = bit(high) ? byte(255) : byte (0);
- while (result.m_data.size() < result_size)
- result.m_data.append(1,extend);
- // now set the relevant bits
- for (unsigned i = low; i <= high; i++)
- result.preset(i-low, bit(i));
- }
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // testing operations
-
- bool inf::negative (void) const
- {
- return bit(indexable_bits()-1);
- }
-
- bool inf::natural (void) const
- {
- return !negative();
- }
-
- bool inf::positive (void) const
- {
- return natural() && !zero();
- }
-
- bool inf::zero (void) const
- {
- for (std::string::size_type i = 0; i < m_data.size(); i++)
- if (m_data[i] != 0)
- return false;
- return true;
- }
-
- bool inf::non_zero (void) const
- {
- return !zero();
- }
-
- bool inf::operator ! (void) const
- {
- return zero();
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // comparison operators
-
- bool inf::operator == (const inf& r) const
- {
- // Two infs are equal if they are numerically equal, even if they are
- // different sizes (i.e. they could be non-reduced values).
- // This makes life a little more complicated than if I could assume that values were reduced.
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = bytes; i--; )
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- if (l_byte != r_byte)
- return false;
- }
- return true;
- }
-
- bool inf::operator != (const inf& r) const
- {
- return !operator==(r);
- }
-
- bool inf::operator < (const inf& r) const
- {
- // This could be implemented in terms of subtraction. However, it can be
- // simplified since there is no need to calculate the accurate difference,
- // just the direction of the difference. I compare from msB down and as
- // soon as a byte difference is found, that defines the ordering. The
- // problem is that in 2's-complement, all negative values are greater than
- // all natural values if you just do a straight unsigned comparison. I
- // handle this by doing a preliminary test for different signs.
-
- // For example, a 3-bit signed type has the coding:
- // 000 = 0
- // ...
- // 011 = 3
- // 100 = -4
- // ...
- // 111 = -1
-
- // So, for natural values, the ordering of the integer values is the
- // ordering of the bit patterns. Similarly, for negative values, the
- // ordering of the integer values is the ordering of the bit patterns
- // However, the bit patterns for the negative values are *greater than*
- // the natural values. This is a side-effect of the naffness of
- // 2's-complement representation
-
- // first handle the case of comparing two values with different signs
- bool l_sign = negative();
- bool r_sign = r.negative();
- if (l_sign != r_sign)
- {
- // one argument must be negative and the other natural
- // the left is less if it is the negative one
- return l_sign;
- }
- // the arguments are the same sign
- // so the ordering is a simple unsigned byte-by-byte comparison
- // However, this is complicated by the possibility that the values could be different lengths
- byte l_extend = l_sign ? byte(255) : byte (0);
- byte r_extend = r_sign ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = bytes; i--; )
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- if (l_byte != r_byte)
- return l_byte < r_byte;
- }
- // if I get here, the two are equal, so that is not less-than
- return false;
- }
-
- bool inf::operator <= (const inf& r) const
- {
- return !(r < *this);
- }
-
- bool inf::operator > (const inf& r) const
- {
- return r < *this;
- }
-
- bool inf::operator >= (const inf& r) const
- {
- return !(*this < r);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // logical operators
-
- inf& inf::invert (void)
- {
- for (std::string::size_type i = 0; i < m_data.size(); i++)
- m_data[i] = ~m_data[i];
- return *this;
- }
-
- inf inf::operator ~ (void) const
- {
- inf result(*this);
- result.invert();
- return result;
- }
-
- inf& inf::operator &= (const inf& r)
- {
- // bitwise AND is extended to the length of the largest argument
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = 0; i < bytes; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- byte result = l_byte & r_byte;
- if (i < m_data.size())
- m_data[i] = result;
- else
- m_data.append(1,result);
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator & (const inf& r) const
- {
- inf result(*this);
- result &= r;
- return result;
- }
-
- inf& inf::operator |= (const inf& r)
- {
- // bitwise OR is extended to the length of the largest argument
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = 0; i < bytes; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- byte result = l_byte | r_byte;
- if (i < m_data.size())
- m_data[i] = result;
- else
- m_data.append(1,result);
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator | (const inf& r) const
- {
- inf result(*this);
- result |= r;
- return result;
- }
-
- inf& inf::operator ^= (const inf& r)
- {
- // bitwise XOR is extended to the length of the largest argument
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = 0; i < bytes; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- byte result = l_byte ^ r_byte;
- if (i < m_data.size())
- m_data[i] = result;
- else
- m_data.append(1,result);
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator ^ (const inf& r) const
- {
- inf result(*this);
- result ^= r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // shift operators all preserve the value by increasing the word size
-
- inf& inf::operator <<= (unsigned shift)
- {
- // left shift is a shift towards the msb, with 0s being shifted in at the lsb
- // split this into a byte shift followed by a bit shift
-
- // first expand the value to be big enough for the result
- std::string::size_type new_size = (indexable_bits() + shift + 7) / 8;
- byte extend = negative() ? byte(255) : byte (0);
- while (m_data.size() < new_size)
- m_data.append(1,extend);
- // now do the byte shift
- unsigned byte_shift = shift/8;
- if (byte_shift > 0)
- {
- for (std::string::size_type b = new_size; b--; )
- m_data[b] = (b >= byte_shift) ? m_data[b-byte_shift] : byte(0);
- }
- // and finally the bit shift
- unsigned bit_shift = shift%8;
- if (bit_shift > 0)
- {
- for (std::string::size_type b = new_size; b--; )
- {
- byte current = byte(m_data[b]);
- byte previous = b > 0 ? m_data[b-1] : byte(0);
- m_data[b] = (current << bit_shift) | (previous >> (8 - bit_shift));
- }
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator << (unsigned shift) const
- {
- inf result(*this);
- result <<= shift;
- return result;
- }
-
- inf& inf::operator >>= (unsigned shift)
- {
- // right shift is a shift towards the lsb, with sign bits being shifted in at the msb
- // split this into a byte shift followed by a bit shift
-
- // a byte of sign bits
- byte extend = negative() ? byte(255) : byte (0);
- // do the byte shift
- unsigned byte_shift = shift/8;
- if (byte_shift > 0)
- {
- for (std::string::size_type b = 0; b < m_data.size(); b++)
- m_data[b] = (b + byte_shift < m_data.size()) ? m_data[b+byte_shift] : extend;
- }
- // and finally the bit shift
- unsigned bit_shift = shift%8;
- if (bit_shift > 0)
- {
- for (std::string::size_type b = 0; b < m_data.size(); b++)
- {
- byte current = byte(m_data[b]);
- byte next = ((b+1) < m_data.size()) ? m_data[b+1] : extend;
- byte shifted = (current >> bit_shift) | (next << (8 - bit_shift));
- m_data[b] = shifted;
- }
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator >> (unsigned shift) const
- {
- inf result(*this);
- result >>= shift;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // negation operators
-
- inf& inf::negate (void)
- {
- // do 2's-complement negation
- // equivalent to inversion plus one
- invert();
- operator += (inf(1));
- return *this;
- }
-
- inf inf::operator - (void) const
- {
- inf result(*this);
- result.negate();
- return result;
- }
-
- inf& inf::abs(void)
- {
- if (negative()) negate();
- return *this;
- }
-
- inf abs(const inf& i)
- {
- inf result = i;
- result.abs();
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // addition operators
-
- inf& inf::operator += (const inf& r)
- {
- // do 2's-complement addition
- // Note that the addition can give a result that is larger than either argument
- byte carry = 0;
- std::string::size_type max_size = maximum(m_data.size(),r.m_data.size());
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- for (std::string::size_type i = 0; i < max_size; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- // calculate the addition in a type that is bigger than a byte in order to catch the carry-out
- unsigned short result = ((unsigned short)(l_byte)) + ((unsigned short)(r_byte)) + carry;
- // now truncate the result to get the lsB
- if (i < m_data.size())
- m_data[i] = byte(result);
- else
- m_data.append(1,byte(result));
- // and capture the carry out by grabbing the second byte of the result
- carry = byte(result >> 8);
- }
- // if the result overflowed or underflowed, add an extra byte to catch it
- unsigned short result = ((unsigned short)(l_extend)) + ((unsigned short)(r_extend)) + carry;
- if (byte(result) != (negative() ? byte(255) : byte(0)))
- m_data.append(1,byte(result));
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator + (const inf& r) const
- {
- inf result(*this);
- result += r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // subtraction operators
-
- inf& inf::operator -= (const inf& r)
- {
- // subtraction is defined in terms of negation and addition
- inf negated = -r;
- operator += (negated);
- return *this;
- }
-
- inf inf::operator - (const inf& r) const
- {
- inf result(*this);
- result -= r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // multiplication operators
-
- inf& inf::operator *= (const inf& r)
- {
- // 2's complement multiplication
- // one day I'll do a more efficient version than this based on the underlying representation
- inf left(*this);
- inf right = r;
- // make the right value natural but preserve its sign for later
- bool right_negative = right.negative();
- right.abs();
- // implemented as a series of conditional additions
- operator = (0);
- // left.resize(right.bits() + left.bits() - 1);
- left <<= right.bits()-1;
- for (unsigned i = right.bits(); i--; )
- {
- if (right[i])
- operator += (left);
- left >>= 1;
- }
- if (right_negative)
- negate();
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator * (const inf& r) const
- {
- inf result(*this);
- result *= r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // division and remainder operators
-
- std::pair<inf,inf> inf::divide(const inf& right) const throw(divide_by_zero)
- {
- if (right.zero())
- throw divide_by_zero("stlplus::inf::divide");
- inf numerator(*this);
- inf denominator = right;
- // make the numerator natural but preserve the sign for later
- bool numerator_negative = numerator.negative();
- numerator.abs();
- // same with the denominator
- bool denominator_negative = denominator.negative();
- denominator.abs();
- // the quotient and remainder will form the result
- // start with the quotiont zero and the remainder equal to the whole of the
- // numerator, then do trial subtraction from this
- inf quotient;
- inf remainder = numerator;
- // there's nothing more to do if the numerator is smaller than the denominator
- // but otherwise do the division
- if (numerator.bits() >= denominator.bits())
- {
- // make the quotient big enough to take the result
- quotient.resize(numerator.bits());
- // start with the numerator shifted to the far left
- unsigned shift = numerator.bits() - denominator.bits();
- denominator <<= shift;
- // do the division by repeated subtraction,
- for (unsigned i = shift+1; i--; )
- {
- if (remainder >= denominator)
- {
- remainder -= denominator;
- quotient.set(i);
- }
- denominator >>= 1;
- }
- }
- // now adjust the signs
- // x/(-y) == (-x)/y == -(x/y)
- if (numerator_negative != denominator_negative)
- quotient.negate();
- quotient.reduce();
- // x%(-y) == x%y and (-x)%y == -(x%y)
- if (numerator_negative)
- remainder.negate();
- remainder.reduce();
- return std::pair<inf,inf>(quotient,remainder);
- }
-
- inf& inf::operator /= (const inf& r) throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- operator=(result.first);
- return *this;
- }
-
- inf inf::operator / (const inf& r) const throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- return result.first;
- }
-
- inf& inf::operator %= (const inf& r) throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- operator=(result.second);
- return *this;
- }
-
- inf inf::operator % (const inf& r) const throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- return result.second;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // prefix (void) and postfix (int) operators
-
- inf& inf::operator ++ (void)
- {
- operator += (inf(1));
- return *this;
- }
-
- inf inf::operator ++ (int)
- {
- inf old(*this);
- operator += (inf(1));
- return old;
- }
-
- inf& inf::operator -- (void)
- {
- operator -= (inf(1));
- return *this;
- }
-
- inf inf::operator -- (int)
- {
- inf old(*this);
- operator -= (inf(1));
- return old;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // string representation and I/O routines
-
- std::string inf::to_string(unsigned radix) const
- throw(std::invalid_argument)
- {
- std::string result;
- convert_to_string(*this, result, radix);
- return result;
- }
-
- inf& inf::from_string(const std::string& value, unsigned radix)
- throw(std::invalid_argument)
- {
- convert_from_string(value, *this, radix);
- return *this;
- }
-
- std::ostream& operator << (std::ostream& str, const inf& i)
- {
- try
- {
- // get radix
- unsigned radix = 10;
- if (str.flags() & std::ios_base::oct)
- radix = 8;
- if (str.flags() & std::ios_base::hex)
- radix = 16;
- // the field width is handled by iostream, so I don't need to handle it as well
- // generate the string representation then print it
- str << i.to_string(radix);
- }
- catch(const std::invalid_argument)
- {
- str.setstate(std::ios_base::badbit);
- }
- return str;
- }
-
- std::istream& operator >> (std::istream& str, inf& i)
- {
- try
- {
- // get radix
- unsigned radix = 10;
- if (str.flags() & std::ios_base::oct)
- radix = 8;
- if (str.flags() & std::ios_base::hex)
- radix = 16;
- // now get the string image of the value
- std::string image;
- str >> image;
- // and convert to inf
- i.from_string(image, radix);
- }
- catch(const std::invalid_argument)
- {
- str.setstate(std::ios_base::badbit);
- }
- return str;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // diagnostic dump
- // just convert to hex
-
- std::string inf::image_debug(void) const
- {
- // create this dump in the human-readable form, i.e. msB to the left
- std::string result = "0x";
- for (std::string::size_type i = m_data.size(); i--; )
- {
- byte current = m_data[i];
- byte msB = (current & byte(0xf0)) >> 4;
- result += to_char[msB];
- byte lsB = (current & byte(0x0f));
- result += to_char[lsB];
- }
- return result;
- }
-
- const std::string& inf::get_bytes(void) const
- {
- return m_data;
- }
-
- void inf::set_bytes(const std::string& data)
- {
- m_data = data;
- }
-
-} // end namespace stlplus
diff --git a/src/tool/moneycount/inf.hpp b/src/tool/moneycount/inf.hpp deleted file mode 100644 index f28541a..0000000 --- a/src/tool/moneycount/inf.hpp +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef STLPLUS_INF
-#define STLPLUS_INF
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// An infinite-precision integer class. This allows calculations on large
-// integers to be performed without overflow.
-
-// this class can throw the following exceptions:
-// std::out_of_range
-// std::overflow_error
-// std::invalid_argument
-// stlplus::divide_by_zero // why doesn't std have this?
-// all of these are derivations of the baseclass:
-// std::logic_error
-// So you can catch all of them by catching the baseclass
-
-// Warning: inf was never intended to be fast, it is just for programs which
-// need a bit of infinite-precision integer arithmetic. For high-performance
-// processing, use the Gnu Multi-Precision (GMP) library. The inf type is just
-// easier to integrate and is already ported to all platforms and compilers
-// that STLplus is ported to.
-
-////////////////////////////////////////////////////////////////////////////////
-#include "portability_fixes.hpp"
-#include "portability_exceptions.hpp"
-#include <string>
-#include <iostream>
-
-////////////////////////////////////////////////////////////////////////////////
-
-namespace stlplus
-{
-
-////////////////////////////////////////////////////////////////////////////////
-
- class inf
- {
- public:
-
- //////////////////////////////////////////////////////////////////////////////
- // constructors and assignments initialise the inf
-
- // the void constructor initialises to zero, the others initialise to the
- // value of the C integer type or the text value contained in the string
-
- inf(void);
- explicit inf(short);
- explicit inf(unsigned short);
- explicit inf(int);
- explicit inf(unsigned);
- explicit inf(long);
- explicit inf(unsigned long);
- explicit inf(const std::string&) throw(std::invalid_argument);
- inf(const inf&);
-
- ~inf(void);
-
- // assignments with equivalent behaviour to the constructors
-
- inf& operator = (short);
- inf& operator = (unsigned short);
- inf& operator = (int);
- inf& operator = (unsigned);
- inf& operator = (long);
- inf& operator = (unsigned long);
- inf& operator = (const std::string&) throw(std::invalid_argument);
- inf& operator = (const inf&);
-
- //////////////////////////////////////////////////////////////////////////////
- // conversions back to the C types
- // truncate: controls the behaviour when the value is too long for the result
- // true: truncate the value
- // false: throw an exception
-
- short to_short(bool truncate = true) const throw(std::overflow_error);
- unsigned short to_unsigned_short(bool truncate = true) const throw(std::overflow_error);
-
- int to_int(bool truncate = true) const throw(std::overflow_error);
- unsigned to_unsigned(bool truncate = true) const throw(std::overflow_error);
-
- long to_long(bool truncate = true) const throw(std::overflow_error);
- unsigned long to_unsigned_long(bool truncate = true) const throw(std::overflow_error);
-
- //////////////////////////////////////////////////////////////////////////////
- // bitwise manipulation
-
- void resize(unsigned bits);
- void reduce(void);
-
- // the number of significant bits in the value
- unsigned bits (void) const;
- unsigned size (void) const;
-
- // the number of bits that can be accessed by the bit() method (=bits() rounded up to the next byte)
- unsigned indexable_bits(void) const;
-
- bool bit (unsigned index) const throw(std::out_of_range);
- bool operator [] (unsigned index) const throw(std::out_of_range);
-
- void set (unsigned index) throw(std::out_of_range);
- void clear (unsigned index) throw(std::out_of_range);
- void preset (unsigned index, bool value) throw(std::out_of_range);
-
- inf slice(unsigned low, unsigned high) const throw(std::out_of_range);
-
- //////////////////////////////////////////////////////////////////////////////
- // tests for common values or ranges
-
- bool negative (void) const;
- bool natural (void) const;
- bool positive (void) const;
- bool zero (void) const;
- bool non_zero (void) const;
-
- // tests used in if(i) and if(!i)
-// operator bool (void) const;
- bool operator ! (void) const;
-
- //////////////////////////////////////////////////////////////////////////////
- // comparisons
-
- bool operator == (const inf&) const;
- bool operator != (const inf&) const;
- bool operator < (const inf&) const;
- bool operator <= (const inf&) const;
- bool operator > (const inf&) const;
- bool operator >= (const inf&) const;
-
- //////////////////////////////////////////////////////////////////////////////
- // bitwise logic operations
-
- inf& invert (void);
- inf operator ~ (void) const;
-
- inf& operator &= (const inf&);
- inf operator & (const inf&) const;
-
- inf& operator |= (const inf&);
- inf operator | (const inf&) const;
-
- inf& operator ^= (const inf&);
- inf operator ^ (const inf&) const;
-
- inf& operator <<= (unsigned shift);
- inf operator << (unsigned shift) const;
-
- inf& operator >>= (unsigned shift);
- inf operator >> (unsigned shift) const;
-
- //////////////////////////////////////////////////////////////////////////////
- // arithmetic operations
-
- inf& negate (void);
- inf operator - (void) const;
-
- inf& abs(void);
- friend inf abs(const inf&);
-
- inf& operator += (const inf&);
- inf operator + (const inf&) const;
-
- inf& operator -= (const inf&);
- inf operator - (const inf&) const;
-
- inf& operator *= (const inf&);
- inf operator * (const inf&) const;
-
- inf& operator /= (const inf&) throw(divide_by_zero);
- inf operator / (const inf&) const throw(divide_by_zero);
-
- inf& operator %= (const inf&) throw(divide_by_zero);
- inf operator % (const inf&) const throw(divide_by_zero);
-
- // combined division operator - returns the result pair(quotient,remainder) in one go
- std::pair<inf,inf> divide(const inf&) const throw(divide_by_zero);
-
- //////////////////////////////////////////////////////////////////////////////
- // pre- and post- increment and decrement
-
- inf& operator ++ (void);
- inf operator ++ (int);
- inf& operator -- (void);
- inf operator -- (int);
-
- //////////////////////////////////////////////////////////////////////////////
- // string representation and I/O
-
- std::string image_debug(void) const;
-
- // conversion to a string representation
- // radix must be 10, 2, 8 or 16
- std::string to_string(unsigned radix = 10) const
- throw(std::invalid_argument);
-
- // conversion from a string
- // radix == 0 - radix is deduced from the input - assumed 10 unless number is prefixed by 0b, 0 or 0x
- // however, you can specify the radix to be 10, 2, 8 or 16 to force that interpretation
- inf& from_string(const std::string&, unsigned radix = 0)
- throw(std::invalid_argument);
-
- //////////////////////////////////////////////////////////////////////////////
- private:
- std::string m_data;
- public:
- const std::string& get_bytes(void) const;
- void set_bytes(const std::string&);
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // redefine friends for gcc v4.1
-
- inf abs(const inf&);
-
- ////////////////////////////////////////////////////////////////////////////////
-
- std::ostream& operator << (std::ostream&, const inf&);
- std::istream& operator >> (std::istream&, inf&);
-
- ////////////////////////////////////////////////////////////////////////////////
-
-} // end namespace stlplus
-
-#endif
diff --git a/src/tool/moneycount/main.cpp b/src/tool/moneycount/main.cpp deleted file mode 100644 index 2c3d56c..0000000 --- a/src/tool/moneycount/main.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <fstream> -#include <iostream> -#include <vector> -#include <algorithm> -#include <cmath> - -#include "mmo.hpp" -#include "athena_text.hpp" -#include "inf.hpp" - -#define ATHENA_FILE "save/athena.txt" -#define ACCREG_FILE "save/accreg.txt" - -std::vector<int> values; - -void countAthena() -{ - int total = 0; - std::string input; - std::ifstream fp(ATHENA_FILE); - char *buffer = new char[65536]; - - while (fp.good()) - { - std::getline(fp,input); - mmo_charstatus *thisChar = new struct mmo_charstatus; - - strcpy(buffer,input.c_str()); - - if (mmo_char_fromstr(buffer, thisChar)) - { - total++; - values.push_back(thisChar->zeny); - } - - delete thisChar; - } - - - std::cout << "Parsed a total of " << total << " lines in " << ATHENA_FILE << std::endl << std::endl; - - delete [] buffer; - fp.close(); -} - -void countAccReg() -{ - int total = 0; - std::ifstream fp(ACCREG_FILE); - char *buffer = new char[65536]; - while (fp.good()) - { - std::string line; - std::getline(fp, line); - struct accreg *reg = new struct accreg; - - strcpy(buffer, line.c_str()); - - if (accreg_fromstr(buffer, reg)) - { - total++; - for (int i = 0; i < reg->reg_num; i++) - { - if (strcmp(reg->reg[i].str,"#BankAccount") == 0) - { - values.push_back(reg->reg[i].value); - } - } - } - - delete reg; - } - - std::cout << "Parsed a total of " << total << " lines in " << ACCREG_FILE << std::endl << std::endl; - - delete [] buffer; - fp.close(); -} - -stlplus::inf stdDevTotal(0); -stlplus::inf sum(0); -stlplus::inf mean(0); - -bool lessthan (int i,int j) { return (i<j); } -void findstddev(int i) { stdDevTotal += stlplus::inf((stlplus::inf(i) - mean) * (stlplus::inf(i) - mean)); } -void findSum(int i) { sum += stlplus::inf(i); } - -stlplus::inf infsqrt(stlplus::inf &x) -{ - stlplus::inf old(x); - stlplus::inf newv(x / stlplus::inf(2)); - while (old - newv > stlplus::inf(1)) - { - old = newv; - newv = old - (old * old - x) / (stlplus::inf(2) * old); - } - return newv; -} - - -void showStats() -{ - // Reset globals - sum = 0; - mean = 0; - stdDevTotal = 0; - - std::sort(values.begin(), values.end(), lessthan); - std::for_each(values.begin(), values.end(), findSum); - - stlplus::inf total(sum); - stlplus::inf count(values.size()); - stlplus::inf mean(total / count); - - std::for_each(values.begin(), values.end(), findstddev); - - int a4th = stlplus::inf(count / stlplus::inf(4)).to_int(); - int a10th = stlplus::inf(count / stlplus::inf(10)).to_int(); - - int lower = values[0], - - t1 = values[a10th * 1], - t2 = values[a10th * 2], - - q1 = values[a4th * 1], - - t3 = values[a10th * 3], - t4 = values[a10th * 4], - - median = values[a4th * 2], - - t6 = values[a10th * 6], - t7 = values[a10th * 7], - - q3 = values[a4th * 3], - - t8 = values[a10th * 8], - t9 = values[a10th * 9], - - upper = values[count.to_int() - 1]; - - stlplus::inf variance(stdDevTotal / count); - - std::cout << "Sum = " << total - << "\nCount = " << count - << "\nMean = " << mean - << "\nSimple Variance = " << variance - << "\nStandard Deviation = " << infsqrt(variance) - << "\nLower bound = " << lower - << "\n10th Percentile = " << t1 - << "\n20th Percentile = " << t2 - << "\nQ1 = " << q1 - << "\n30th Percentile = " << t3 - << "\n40th Percentile = " << t4 - << "\nMedian = " << median - << "\n60th Percentile = " << t6 - << "\n70th Percentile = " << t7 - << "\nQ3 = " << q3 - << "\n80th Percentile = " << t8 - << "\n90th Percentile = " << t9 - << "\nUpper bound = " << upper << std::endl << std::endl; -} - -int main() -{ - countAthena(); - std::cout << "The stats for player held money is:" << std::endl; - showStats(); - values.clear(); - - countAccReg(); - std::cout << "The stats for bank held money is:" << std::endl; - showStats(); - - return 0; -} - diff --git a/src/tool/moneycount/mmo.hpp b/src/tool/moneycount/mmo.hpp deleted file mode 100644 index beb29c5..0000000 --- a/src/tool/moneycount/mmo.hpp +++ /dev/null @@ -1,309 +0,0 @@ -// $Id: mmo.h,v 1.3 2004/09/25 20:12:25 PoW Exp $ -// Original : mmo.h 2003/03/14 12:07:02 Rev.1.7 - -#ifndef MMO_HPP -#define MMO_HPP - -#include <time.h> - -#define FIFOSIZE_SERVERLINK 256*1024 - -// set to 0 to not check IP of player between each server. -// set to another value if you want to check (1) -#define CMP_AUTHFIFO_IP 1 - -#define CMP_AUTHFIFO_LOGIN2 1 - -#define MAX_MAP_PER_SERVER 512 -#define MAX_INVENTORY 100 -#define MAX_AMOUNT 30000 -#define MAX_ZENY 1000000000 // 1G zeny -#define MAX_CART 100 -#define MAX_SKILL 450 -#define GLOBAL_REG_NUM 96 -#define ACCOUNT_REG_NUM 16 -#define ACCOUNT_REG2_NUM 16 -#define DEFAULT_WALK_SPEED 150 -#define MIN_WALK_SPEED 0 -#define MAX_WALK_SPEED 1000 -#define MAX_STORAGE 300 -#define MAX_GUILD_STORAGE 1000 -#define MAX_PARTY 12 -#define MAX_GUILD 120 // increased max guild members to accomodate for +2 increase for extension levels [Valaris] (removed) [PoW] -#define MAX_GUILDPOSITION 20 // increased max guild positions to accomodate for all members [Valaris] (removed) [PoW] -#define MAX_GUILDEXPLUSION 32 -#define MAX_GUILDALLIANCE 16 -#define MAX_GUILDSKILL 8 -#define MAX_GUILDCASTLE 24 // increased to include novice castles [Valaris] -#define MAX_GUILDLEVEL 50 - -#define MIN_HAIR_STYLE battle_config.min_hair_style -#define MAX_HAIR_STYLE battle_config.max_hair_style -#define MIN_HAIR_COLOR battle_config.min_hair_color -#define MAX_HAIR_COLOR battle_config.max_hair_color -#define MIN_CLOTH_COLOR battle_config.min_cloth_color -#define MAX_CLOTH_COLOR battle_config.max_cloth_color - -// for produce -#define MIN_ATTRIBUTE 0 -#define MAX_ATTRIBUTE 4 -#define ATTRIBUTE_NORMAL 0 -#define MIN_STAR 0 -#define MAX_STAR 3 - -#define MIN_PORTAL_MEMO 0 -#define MAX_PORTAL_MEMO 2 - -#define MAX_STATUS_TYPE 5 - -#define CHAR_CONF_NAME "conf/char_athena.conf" - -struct account -{ - int account_id; - char name[50]; - char password[50]; - char lastlogin[50]; - char sex; - int num_logins; - int state; - char email[50]; - char error_message[50]; - long valitidy_time; - char last_ip[50]; - char memo[50]; - long ban_time; -}; - - -struct item -{ - int id; - short nameid; - short amount; - unsigned short equip; - char identify; - char refine; - char attribute; - short card[4]; - short broken; -}; - -struct point -{ - char map[24]; - short x, y; -}; - -struct skill -{ - unsigned short id, lv, flags; -}; - -struct global_reg -{ - char str[32]; - int value; -}; - -struct accreg -{ - int account_id, reg_num; - struct global_reg reg[ACCOUNT_REG_NUM]; -}; - -struct mmo_charstatus -{ - int char_id; - int account_id; - int partner_id; - - int base_exp, job_exp, zeny; - - short classb; - short status_point, skill_point; - int hp, max_hp, sp, max_sp; - short option, karma, manner; - short hair, hair_color, clothes_color; - int party_id, guild_id; - - short weapon, shield; - short head_top, head_mid, head_bottom; - - char name[24]; - unsigned char base_level, job_level; - short str, agi, vit, int_, dex, luk; - unsigned char char_num, sex; - - unsigned long mapip; - unsigned int mapport; - - struct point last_point, save_point, memo_point[10]; - struct item inventory[MAX_INVENTORY], cart[MAX_CART]; - struct skill skill[MAX_SKILL]; - int global_reg_num; - struct global_reg global_reg[GLOBAL_REG_NUM]; - int account_reg_num; - struct global_reg account_reg[ACCOUNT_REG_NUM]; - int account_reg2_num; - struct global_reg account_reg2[ACCOUNT_REG2_NUM]; -}; - -struct storage -{ - int dirty; - int account_id; - short storage_status; - short storage_amount; - struct item storage_[MAX_STORAGE]; -}; - -struct guild_storage -{ - int dirty; - int guild_id; - short storage_status; - short storage_amount; - struct item storage_[MAX_GUILD_STORAGE]; -}; - -struct map_session_data; - -struct gm_account -{ - int account_id; - int level; -}; - -struct party_member -{ - int account_id; - char name[24], map[24]; - int leader, online, lv; - struct map_session_data *sd; -}; - -struct party -{ - int party_id; - char name[24]; - int exp; - int item; - struct party_member member[MAX_PARTY]; -}; - -struct guild_member -{ - int account_id, char_id; - short hair, hair_color, gender, classb, lv; - int exp, exp_payper; - short online, position; - int rsv1, rsv2; - char name[24]; - struct map_session_data *sd; -}; - -struct guild_position -{ - char name[24]; - int mode; - int exp_mode; -}; - -struct guild_alliance -{ - int opposition; - int guild_id; - char name[24]; -}; - -struct guild_explusion -{ - char name[24]; - char mes[40]; - char acc[40]; - int account_id; - int rsv1, rsv2, rsv3; -}; - -struct guild_skill -{ - int id, lv; -}; - -struct guild -{ - int guild_id; - short guild_lv, connect_member, max_member, average_lv; - int exp, next_exp, skill_point, castle_id; - char name[24], master[24]; - struct guild_member member[MAX_GUILD]; - struct guild_position position[MAX_GUILDPOSITION]; - char mes1[60], mes2[120]; - int emblem_len, emblem_id; - char emblem_data[2048]; - struct guild_alliance alliance[MAX_GUILDALLIANCE]; - struct guild_explusion explusion[MAX_GUILDEXPLUSION]; - struct guild_skill skill[MAX_GUILDSKILL]; -}; - -struct guild_castle -{ - int castle_id; - char map_name[24]; - char castle_name[24]; - char castle_event[24]; - int guild_id; - int economy; - int defense; - int triggerE; - int triggerD; - int nextTime; - int payTime; - int createTime; - int visibleC; - int visibleG0; - int visibleG1; - int visibleG2; - int visibleG3; - int visibleG4; - int visibleG5; - int visibleG6; - int visibleG7; - int Ghp0; // added Guardian HP [Valaris] - int Ghp1; - int Ghp2; - int Ghp3; - int Ghp4; - int Ghp5; - int Ghp6; - int Ghp7; - int GID0; - int GID1; - int GID2; - int GID3; - int GID4; - int GID5; - int GID6; - int GID7; // end addition [Valaris] -}; -struct square -{ - int val1[5]; - int val2[5]; -}; - -enum -{ - GBI_EXP = 1, // ?M???h??EXP - GBI_GUILDLV = 2, // ?M???h??Lv - GBI_SKILLPOINT = 3, // ?M???h?~X?L???|?C???g - GBI_SKILLLV = 4, // ?M???h?X?L??Lv - - GMI_POSITION = 0, // ?????o?[???E??X - GMI_EXP = 1, // ?????o?[??EXP - -}; - -#endif // MMO_HPP - diff --git a/src/tool/moneycount/portability_exceptions.hpp b/src/tool/moneycount/portability_exceptions.hpp deleted file mode 100644 index c66b7bf..0000000 --- a/src/tool/moneycount/portability_exceptions.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef STLPLUS_PORTABILITY_EXCEPTIONS
-#define STLPLUS_PORTABILITY_EXCEPTIONS
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// Adds missing arithmetic exceptions used in this library but missing from std
-
-////////////////////////////////////////////////////////////////////////////////
-#include "portability_fixes.hpp"
-#include <string>
-#include <stdexcept>
-
-namespace stlplus
-{
-
- ////////////////////////////////////////////////////////////////////////////////
- // thrown by division when the divisor is zero
- // This is a subclass of std::logic_error so can be caught by a generic catch clause for the superclass
-
- class divide_by_zero : public std::logic_error {
- public:
- divide_by_zero (const std::string& what_arg): std::logic_error (what_arg) { }
- };
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // end namespace stlplus
-
-#endif
diff --git a/src/tool/moneycount/portability_fixes.cpp b/src/tool/moneycount/portability_fixes.cpp deleted file mode 100644 index e26ee28..0000000 --- a/src/tool/moneycount/portability_fixes.cpp +++ /dev/null @@ -1,39 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-////////////////////////////////////////////////////////////////////////////////
-#include "portability_fixes.hpp"
-
-#ifdef MSWINDOWS
-#include "windows.h"
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// problems with missing functions
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef MSWINDOWS
-unsigned sleep(unsigned seconds)
-{
- Sleep(1000*seconds);
- // should return remaining time if interrupted - however Windoze Sleep cannot be interrupted
- return 0;
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Function for establishing endian-ness
-////////////////////////////////////////////////////////////////////////////////
-
-bool stlplus::little_endian(void)
-{
- int sample = 1;
- char* sample_bytes = (char*)&sample;
- return sample_bytes[0] != 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
diff --git a/src/tool/moneycount/portability_fixes.hpp b/src/tool/moneycount/portability_fixes.hpp deleted file mode 100644 index b6a030c..0000000 --- a/src/tool/moneycount/portability_fixes.hpp +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef STLPLUS_PORTABILITY_FIXES
-#define STLPLUS_PORTABILITY_FIXES
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// Contains work arounds for OS or Compiler specific problems to try to make
-// them look more alike
-
-// It is strongly recommended that this header be included as the first
-// #include in every source file
-
-////////////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////////////
-// Problem with MicroSoft defining two different macros to identify Windows
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(_WIN32) || defined(_WIN32_WCE)
-#define MSWINDOWS
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Problems with unnecessary or unfixable compiler warnings
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef _MSC_VER
-// Microsoft Visual Studio
-// shut up the following irritating warnings
-// 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
-// 4305 - VC6, identifier type was converted to a smaller type
-// 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
-// 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
-// 4290 - VC6, C++ exception specification ignored
-// 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
-// 4675 - VC7.1, "change" in function overload resolution _might_ have altered program
-// 4996 - VC8, 'xxxx' was declared deprecated
-#pragma warning(disable: 4786 4305 4503 4309 4290 4800 4675 4996)
-#endif
-
-#ifdef __BORLANDC__
-// Borland
-// Shut up the following irritating warnings
-// 8026 - Functions with exception specifications are not expanded inline
-// 8027 - Functions with xxx are not expanded inline
-#pragma warn -8026
-#pragma warn -8027
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Problems with redefinition of min/max in various different versions of library headers
-////////////////////////////////////////////////////////////////////////////////
-
-// The Windows headers define macros called max/min which conflict with the templates std::max and std::min.
-// So, to avoid conflicts, MS removed the std::max/min rather than fixing the problem!
-// From Visual Studio .NET (SV7, compiler version 13.00) the STL templates have been added correctly.
-// For MFC compatibility, only undef min and max in non-MFC programs - some bits of MFC
-// use macro min/max in headers.
-
-// I've created extra template function definitions minimum/maximum that avoid all the problems above
-
-namespace stlplus
-{
- template<typename T> const T& maximum(const T& l, const T& r) {return l > r ? l : r;}
- template<typename T> const T& minimum(const T& l, const T& r) {return l < r ? l : r;}
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Problems with differences between namespaces
-////////////////////////////////////////////////////////////////////////////////
-
-// Note: not sure of the relevance of this - maybe deprecated?
-// problem in gcc pre-v3 where the sub-namespaces in std aren't present
-// this mean that the statement "using namespace std::rel_ops" created an error because the namespace didn't exist
-
-// I've done a fix here that creates an empty namespace for this case, but I
-// do *not* try to move the contents of std::rel_ops into namespace std
-// This fix only works if you use "using namespace std::rel_ops" to bring in the template relational operators (e.g. != defined i.t.o. ==)
-
-#ifdef __GNUC__
-namespace std
-{
- namespace rel_ops
- {
- }
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// problems with missing functions
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef MSWINDOWS
-unsigned sleep(unsigned seconds);
-#else
-#include <unistd.h>
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Function for establishing endian-ness
-////////////////////////////////////////////////////////////////////////////////
-// Different machine architectures store data using different byte orders.
-// This is referred to as Big- and Little-Endian Byte Ordering.
-//
-// The issue is: where does a pointer to an integer type actually point?
-//
-// In both conventions, the address points to the left of the word but:
-// Big-Endian - The most significant byte is on the left end of a word
-// Little-Endian - The least significant byte is on the left end of a word
-//
-// Bytes are addressed left to right, so in big-endian order byte 0 is the
-// msB, whereas in little-endian order byte 0 is the lsB. For example,
-// Intel-based machines store data in little-endian byte order so byte 0 is
-// the lsB.
-//
-// This function establishes byte order at run-time
-
-namespace stlplus
-{
- bool little_endian(void);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-#endif
|