Browse Source

Implement Cornerstone of the World functionality

pull/922/head^2
Anders Jenbo 5 years ago
parent
commit
0c8664b016
  1. 2
      3rdParty/Storm/Source/storm.h
  2. 35
      Source/items.cpp
  3. 2
      SourceX/storm/storm.cpp

2
3rdParty/Storm/Source/storm.h vendored

@ -290,7 +290,7 @@ SMemFree(
bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue = false); bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue = false);
bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, int *dataSize = NULL); bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, int *dataSize = NULL);
void setIniValue(const char *sectionName, const char *keyName, char *value, int len = 0); void setIniValue(const char *sectionName, const char *keyName, const char *value, int len = 0);
BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value); BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value);
BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result); BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result);

35
Source/items.cpp

@ -3037,21 +3037,47 @@ void RecreateEar(int ii, WORD ic, int iseed, int Id, int dur, int mdur, int ch,
void items_427A72() void items_427A72()
{ {
PkItemStruct id; PkItemStruct id;
char hexId[sizeof(PkItemStruct) * 2 + 1];
BYTE *buffer;
if (CornerStone.activated) { if (CornerStone.activated) {
if (CornerStone.item.IDidx >= 0) { if (CornerStone.item.IDidx >= 0) {
PackItem(&id, &CornerStone.item); PackItem(&id, &CornerStone.item);
setIniValue("Hellfire", off_4A5AC4, (char *)&id, 19); buffer = (BYTE *)&id;
for (int i = 0; i < sizeof(PkItemStruct); i++) {
sprintf(&hexId[i * 2], "%02X", buffer[i]);
}
setIniValue("Hellfire", off_4A5AC4, hexId, sizeof(hexId));
} else { } else {
setIniValue("Hellfire", off_4A5AC4, (char *)"", 1); setIniValue("Hellfire", off_4A5AC4, "", 1);
} }
} }
} }
int char2int(char input)
{
if (input >= '0' && input <= '9')
return input - '0';
if (input >= 'A' && input <= 'F')
return input - 'A' + 10;
return 0;
}
void hex2bin(const char *src, int bytes, char *target)
{
for (int i = 0; i < bytes; i++, src += 2) {
target[i] = (char2int(*src) << 4) | char2int(src[1]);
}
}
void items_427ABA(int x, int y) void items_427ABA(int x, int y)
{ {
int i, ii; int i, ii;
int dwSize; int dwSize;
PkItemStruct PkSItem; PkItemStruct PkSItem;
char hexPkSItem[sizeof(PkItemStruct) * 2 + 1];
BYTE *buffer;
if (CornerStone.activated || x == 0 || y == 0) { if (CornerStone.activated || x == 0 || y == 0) {
return; return;
@ -3070,8 +3096,9 @@ void items_427ABA(int x, int y)
dItem[x][y] = 0; dItem[x][y] = 0;
} }
dwSize = 0; dwSize = 0;
if (getIniValue("Hellfire", off_4A5AC4, (char *)&PkSItem, sizeof(PkSItem), &dwSize)) { if (getIniValue("Hellfire", off_4A5AC4, hexPkSItem, sizeof(hexPkSItem), &dwSize)) {
if (dwSize == sizeof(PkSItem)) { if (dwSize >= sizeof(PkItemStruct) * 2) {
hex2bin(hexPkSItem, sizeof(PkItemStruct), (char *)&PkSItem);
ii = itemavail[0]; ii = itemavail[0];
dItem[x][y] = ii + 1; dItem[x][y] = ii + 1;
itemavail[0] = itemavail[MAXITEMS - numitems - 1]; itemavail[0] = itemavail[MAXITEMS - numitems - 1];

2
SourceX/storm/storm.cpp

@ -294,7 +294,7 @@ bool getIniValue(const char *sectionName, const char *keyName, char *string, int
return true; return true;
} }
void setIniValue(const char *sectionName, const char *keyName, char *value, int len) void setIniValue(const char *sectionName, const char *keyName, const char *value, int len)
{ {
radon::File &ini = getIni(); radon::File &ini = getIni();

Loading…
Cancel
Save