mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Simplified the code of travel markers and string_to_case function
Added new addrs to CheckAddress.cpp. Minor edits to some code and documents.
This commit is contained in:
@@ -247,7 +247,7 @@
|
|||||||
// fake perks/traits add mode flags
|
// fake perks/traits add mode flags
|
||||||
#define ADD_PERK_MODE_TRAIT (1) // add to the player's traits
|
#define ADD_PERK_MODE_TRAIT (1) // add to the player's traits
|
||||||
#define ADD_PERK_MODE_PERK (2) // add to the player's perks
|
#define ADD_PERK_MODE_PERK (2) // add to the player's perks
|
||||||
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks
|
#define ADD_PERK_MODE_REMOVE (4) // remove from the list of selectable perks (after added to the player)
|
||||||
|
|
||||||
// sfall_funcX macros
|
// sfall_funcX macros
|
||||||
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
#define add_extra_msg_file(name) sfall_func1("add_extra_msg_file", name)
|
||||||
|
|||||||
@@ -700,6 +700,7 @@ optional argument:
|
|||||||
> string sfall_func2("string_to_case", string text, int toCase)
|
> string sfall_func2("string_to_case", string text, int toCase)
|
||||||
- converts all letters in the given string to the specified case
|
- converts all letters in the given string to the specified case
|
||||||
- toCase: 0 - lowercase, 1 - uppercase
|
- toCase: 0 - lowercase, 1 - uppercase
|
||||||
|
- NOTE: this function works only for English letters of A-Z/a-z
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
------ MORE INFO -------
|
------ MORE INFO -------
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ namespace sfall
|
|||||||
std::multimap<long, long> writeAddress;
|
std::multimap<long, long> writeAddress;
|
||||||
|
|
||||||
static std::vector<long> excludeAddr = {
|
static std::vector<long> excludeAddr = {
|
||||||
0x42a14f, 0x42a178,
|
0x42A14F, 0x42A178,
|
||||||
|
0x44E949, 0x44E94A, 0x44E937, 0x4F5F40, 0x4CB850, // from movies.cpp
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HackPair {
|
struct HackPair {
|
||||||
@@ -72,6 +73,7 @@ static std::vector<HackPair> hackAddr = {
|
|||||||
{0x484B18, 1}, {0x484B19, 4}, // hookcall
|
{0x484B18, 1}, {0x484B19, 4}, // hookcall
|
||||||
// module: Movies
|
// module: Movies
|
||||||
{0x44E937, 1}, {0x44E938, 4}, {0x44E949, 1}, {0x44E94A, 4}, // hookcalls
|
{0x44E937, 1}, {0x44E938, 4}, {0x44E949, 1}, {0x44E94A, 4}, // hookcalls
|
||||||
|
{0x4F5F40, 1}, {0x4CB850, 1},
|
||||||
// module: Objects
|
// module: Objects
|
||||||
{0x4A364A, 5}, {0x4831D9, 1}, {0x4831DA, 1},
|
{0x4A364A, 5}, {0x4831D9, 1}, {0x4831DA, 1},
|
||||||
{0x4841D6, 1}, {0x4841D7, 4}, // hookcall
|
{0x4841D6, 1}, {0x4841D7, 4}, // hookcall
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ void dlog(const std::string& a, int type) {
|
|||||||
Log.flush();
|
Log.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dlogr(const std::string& a, int type) {
|
void dlogr(const std::string& a, int type) {
|
||||||
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
|
||||||
Log << a << "\n";
|
Log << a << "\n";
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ struct ProtoMem {
|
|||||||
|
|
||||||
void CreateProtoMem(long* srcProto) {
|
void CreateProtoMem(long* srcProto) {
|
||||||
this->proto = reinterpret_cast<long*>(new int32_t[104]); // 416 bytes
|
this->proto = reinterpret_cast<long*>(new int32_t[104]); // 416 bytes
|
||||||
memcpy(this->proto, srcProto, 416);
|
std::memcpy(this->proto, srcProto, 416);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ProtoMem() { delete[] proto; }
|
~ProtoMem() { delete[] proto; }
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void HookScriptClear() {
|
|||||||
for(int i = 0; i < numHooks; i++) {
|
for(int i = 0; i < numHooks; i++) {
|
||||||
hooks[i].clear();
|
hooks[i].clear();
|
||||||
}
|
}
|
||||||
memset(hooksInfo, 0, HOOK_COUNT * sizeof(HooksPositionInfo));
|
std::memset(hooksInfo, 0, HOOK_COUNT * sizeof(HooksPositionInfo));
|
||||||
previousGameMode = 0;
|
previousGameMode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-51
@@ -465,15 +465,17 @@ static void WorldmapViewportPatch() {
|
|||||||
|
|
||||||
///////////////////////// FALLOUT 1 WORLD MAP FEATURES /////////////////////////
|
///////////////////////// FALLOUT 1 WORLD MAP FEATURES /////////////////////////
|
||||||
|
|
||||||
|
enum DotStyleDefault {
|
||||||
|
DotLen = 2,
|
||||||
|
SpaceLen = 2
|
||||||
|
};
|
||||||
|
|
||||||
enum TerrainHoverImage {
|
enum TerrainHoverImage {
|
||||||
width = 100,
|
width = 100,
|
||||||
height = 15,
|
height = 15,
|
||||||
size = width * height
|
size = width * height
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WMAP_DEFAULT_SPACE_LEN (2)
|
|
||||||
#define WMAP_DEFAULT_DOT_LEN (2)
|
|
||||||
|
|
||||||
static std::array<unsigned char, TerrainHoverImage::size> wmTmpBuffer;
|
static std::array<unsigned char, TerrainHoverImage::size> wmTmpBuffer;
|
||||||
static bool isHoveringHotspot = false;
|
static bool isHoveringHotspot = false;
|
||||||
static bool backImageIsCopy = false;
|
static bool backImageIsCopy = false;
|
||||||
@@ -487,47 +489,39 @@ struct DotPosition {
|
|||||||
static std::vector<DotPosition> dots;
|
static std::vector<DotPosition> dots;
|
||||||
|
|
||||||
static unsigned char colorDot = 0;
|
static unsigned char colorDot = 0;
|
||||||
static long spaceLen = WMAP_DEFAULT_SPACE_LEN;
|
static long spaceLen = DotStyleDefault::SpaceLen;
|
||||||
static long dotLen = WMAP_DEFAULT_DOT_LEN;
|
static long dotLen = DotStyleDefault::DotLen;
|
||||||
static long dot_xpos = 0;
|
static long dot_xpos = 0;
|
||||||
static long dot_ypos = 0;
|
static long dot_ypos = 0;
|
||||||
static long terrCount = 0;
|
static size_t terrainCount = 0;
|
||||||
|
|
||||||
static int* optionTerrainDotLen = nullptr;
|
static struct DotStyle {
|
||||||
static int* optionTerrainSpaceLen = nullptr;
|
long dotLen;
|
||||||
|
long spaceLen;
|
||||||
|
} *dotStyle = nullptr;
|
||||||
|
|
||||||
static void AddNewDot() {
|
static void AddNewDot() {
|
||||||
dot_xpos = fo::var::world_xpos;
|
dot_xpos = fo::var::world_xpos;
|
||||||
dot_ypos = fo::var::world_ypos;
|
dot_ypos = fo::var::world_ypos;
|
||||||
|
|
||||||
long terrainId = 0;
|
long* terrain = *(long**)FO_VAR_world_subtile;
|
||||||
if (*(long**)FO_VAR_world_subtile)
|
size_t id = (terrain) ? *terrain : 0;
|
||||||
terrainId = **(long**)FO_VAR_world_subtile;
|
|
||||||
|
|
||||||
// Reinitialize if current terrain has smaller values than previous
|
// Reinitialize if current terrain has smaller values than previous
|
||||||
if (terrainId < terrCount) {
|
if (id < terrainCount) {
|
||||||
if (dotLen > optionTerrainDotLen[terrainId])
|
if (dotLen > dotStyle[id].dotLen) dotLen = dotStyle[id].dotLen;
|
||||||
dotLen = optionTerrainDotLen[terrainId];
|
if (spaceLen > dotStyle[id].spaceLen) spaceLen = dotStyle[id].spaceLen;
|
||||||
if(spaceLen > optionTerrainSpaceLen[terrainId])
|
|
||||||
spaceLen = optionTerrainSpaceLen[terrainId];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dotLen <= 0 && spaceLen) {
|
if (dotLen <= 0 && spaceLen) {
|
||||||
spaceLen--;
|
spaceLen--;
|
||||||
if (!spaceLen) { // set dot length
|
if (!spaceLen) { // set dot length
|
||||||
if (terrainId < terrCount)
|
dotLen = (id < terrainCount) ? dotStyle[id].dotLen : DotStyleDefault::DotLen;
|
||||||
dotLen = optionTerrainDotLen[terrainId];
|
|
||||||
else
|
|
||||||
dotLen = WMAP_DEFAULT_DOT_LEN;
|
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dotLen--;
|
dotLen--;
|
||||||
|
spaceLen = (id < terrainCount) ? dotStyle[id].spaceLen : DotStyleDefault::SpaceLen;
|
||||||
if (terrainId < terrCount)
|
|
||||||
spaceLen = optionTerrainSpaceLen[terrainId];
|
|
||||||
else
|
|
||||||
spaceLen = WMAP_DEFAULT_SPACE_LEN;
|
|
||||||
|
|
||||||
dots.emplace_back(dot_xpos, dot_ypos);
|
dots.emplace_back(dot_xpos, dot_ypos);
|
||||||
}
|
}
|
||||||
@@ -589,8 +583,7 @@ static void __declspec(naked) wmInterfaceRefresh_hook() {
|
|||||||
// player stops moving
|
// player stops moving
|
||||||
dots.clear();
|
dots.clear();
|
||||||
// Reinitialize on next AddNewDot
|
// Reinitialize on next AddNewDot
|
||||||
dotLen = 9999;
|
dotLen = spaceLen = 99;
|
||||||
spaceLen = 9999;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isHoveringHotspot && !fo::var::In_WorldMap) {
|
if (isHoveringHotspot && !fo::var::In_WorldMap) {
|
||||||
@@ -719,40 +712,32 @@ static void WorldMapInterfacePatch() {
|
|||||||
bool showTravelMarkers, showTerrainType;
|
bool showTravelMarkers, showTerrainType;
|
||||||
if (showTravelMarkers = GetConfigInt("Interface", "WorldMapTravelMarkers", 0) != 0) {
|
if (showTravelMarkers = GetConfigInt("Interface", "WorldMapTravelMarkers", 0) != 0) {
|
||||||
dlog("Applying world map travel markers patch.", DL_INIT);
|
dlog("Applying world map travel markers patch.", DL_INIT);
|
||||||
int color = GetConfigInt("Interface", "TravelMarkerColor", 134); // color index in palette: R = 224, G = 0, B = 0
|
|
||||||
|
|
||||||
|
int color = GetConfigInt("Interface", "TravelMarkerColor", 134); // color index in palette: R = 224, G = 0, B = 0
|
||||||
if (color > 255) color = 255; else if (color < 1) color = 1;
|
if (color > 255) color = 255; else if (color < 1) color = 1;
|
||||||
colorDot = color;
|
colorDot = color;
|
||||||
|
|
||||||
auto dotList = GetConfigList("Interface", "TravelMarkerStyles", "", 512);
|
auto dotList = GetConfigList("Interface", "TravelMarkerStyles", "", 512);
|
||||||
size_t count = dotList.size();
|
if (!dotList.empty()) {
|
||||||
if (count) {
|
terrainCount = dotList.size();
|
||||||
optionTerrainSpaceLen = new int[count];
|
dotStyle = new DotStyle[terrainCount];
|
||||||
optionTerrainDotLen = new int[count];
|
|
||||||
terrCount = count;
|
|
||||||
std::vector<std::string> pair;
|
std::vector<std::string> pair;
|
||||||
pair.reserve(2);
|
for (size_t i = 0; i < terrainCount; i++) {
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
split(dotList[i], ':', std::back_inserter(pair), 2);
|
split(dotList[i], ':', std::back_inserter(pair), 2);
|
||||||
if (pair.size() >= 2) {
|
if (pair.size() >= 2) {
|
||||||
optionTerrainDotLen[i] = atoi(pair[0].c_str());
|
int len = atoi(pair[0].c_str());
|
||||||
optionTerrainSpaceLen[i] = atoi(pair[1].c_str());
|
if (len < 1) len = 1; else if (len > 10) len = 10;
|
||||||
if (optionTerrainDotLen[i] < 1)
|
dotStyle[i].dotLen = len;
|
||||||
optionTerrainDotLen[i] = 1;
|
len = atoi(pair[1].c_str());
|
||||||
else if (optionTerrainDotLen[i] > 10)
|
if (len < 1) len = 1; else if (len > 10) len = 10;
|
||||||
optionTerrainDotLen[i] = 10;
|
dotStyle[i].spaceLen = len;
|
||||||
if (optionTerrainSpaceLen[i] < 1)
|
|
||||||
optionTerrainSpaceLen[i] = 1;
|
|
||||||
else if (optionTerrainSpaceLen[i] > 10)
|
|
||||||
optionTerrainSpaceLen[i] = 10;
|
|
||||||
} else {
|
} else {
|
||||||
optionTerrainDotLen[i] = WMAP_DEFAULT_DOT_LEN;
|
dotStyle[i] = {DotStyleDefault::DotLen, DotStyleDefault::SpaceLen};
|
||||||
optionTerrainSpaceLen[i] = WMAP_DEFAULT_SPACE_LEN;
|
|
||||||
}
|
}
|
||||||
pair.clear();
|
pair.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dots.reserve(512);
|
dots.reserve(512);
|
||||||
LoadGameHook::OnGameReset() += []() {
|
LoadGameHook::OnGameReset() += []() {
|
||||||
dots.clear();
|
dots.clear();
|
||||||
@@ -861,8 +846,7 @@ void Interface::init() {
|
|||||||
|
|
||||||
void Interface::exit() {
|
void Interface::exit() {
|
||||||
if (ifaceFrm) delete ifaceFrm;
|
if (ifaceFrm) delete ifaceFrm;
|
||||||
if (optionTerrainDotLen) delete[] optionTerrainDotLen;
|
if (dotStyle) delete[] dotStyle;
|
||||||
if (optionTerrainSpaceLen) delete[] optionTerrainSpaceLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -470,10 +470,7 @@ static std::string strToCase;
|
|||||||
|
|
||||||
void sf_string_to_case(OpcodeContext& ctx) {
|
void sf_string_to_case(OpcodeContext& ctx) {
|
||||||
strToCase = ctx.arg(0).strValue();
|
strToCase = ctx.arg(0).strValue();
|
||||||
if (ctx.arg(1).rawValue())
|
std::transform(strToCase.begin(), strToCase.end(), strToCase.begin(), ctx.arg(1).rawValue() ? ::toupper : ::tolower);
|
||||||
std::transform(strToCase.begin(), strToCase.end(), strToCase.begin(), ::toupper);
|
|
||||||
else
|
|
||||||
std::transform(strToCase.begin(), strToCase.end(), strToCase.begin(), ::tolower);
|
|
||||||
|
|
||||||
ctx.setReturn(strToCase.c_str());
|
ctx.setReturn(strToCase.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user