blob: 8d9e5d37191256e8595c2a70aa26637dfe8dc93f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iostream>
#include "mmo.h"
#include "athena_text.h"
#define ATHENA_FILE "save/athena.txt"
#define ACCREG_FILE "save/accreg.txt"
long long countAthena()
{
long long zeny = 0;
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++;
zeny += thisChar->zeny;
}
else
std::cout << "Could not parse line \"" << buffer << "\"\n";
delete thisChar;
}
std::cout << "Parsed a total of " << total << " lines in " << ATHENA_FILE << std::endl;
delete [] buffer;
fp.close();
return zeny;
}
long long countAccReg()
{
long long zeny = 0;
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)
{
zeny += reg->reg[i].value;
}
}
}
else
{
std::cout << "Could not parse line: \"" << buffer << "\"\n";
}
delete reg;
}
std::cout << "Parsed a total of " << total << " lines in " << ACCREG_FILE << std::endl;
delete [] buffer;
fp.close();
return zeny;
}
int main()
{
long long count = 0;
count = countAthena();
count += countAccReg();
std::cout << "There is a total of " << count << " zeny on this server!" << std::endl;
return 0;
}
|