mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
fix object override strings for scenario editor and plugin.dat
This commit is contained in:
@@ -208,6 +208,7 @@
|
||||
<ClInclude Include="..\src\core\FileStream.hpp" />
|
||||
<ClInclude Include="..\src\core\IDisposable.hpp" />
|
||||
<ClInclude Include="..\src\core\IStream.hpp" />
|
||||
<ClInclude Include="..\src\core\Math.hpp" />
|
||||
<ClInclude Include="..\src\core\Memory.hpp" />
|
||||
<ClInclude Include="..\src\core\StringBuilder.hpp" />
|
||||
<ClInclude Include="..\src\core\StringReader.hpp" />
|
||||
|
||||
@@ -803,5 +803,8 @@
|
||||
<ClInclude Include="..\src\core\StringReader.hpp">
|
||||
<Filter>Source\Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\core\Math.hpp">
|
||||
<Filter>Source\Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
23
src/core/Math.hpp
Normal file
23
src/core/Math.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Common mathematical functions.
|
||||
*/
|
||||
namespace Math {
|
||||
|
||||
template<typename T>
|
||||
T Min(T a, T b) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Max(T a, T b) {
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Clamp(T low, T x, T max) {
|
||||
return Min(Max(low, x), high);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "../common.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "Math.hpp"
|
||||
#include "Memory.hpp"
|
||||
|
||||
/**
|
||||
@@ -107,7 +106,7 @@ private:
|
||||
{
|
||||
if (_capacity > capacity) return;
|
||||
|
||||
_capacity = (std::max<size_t>)(8, _capacity);
|
||||
_capacity = Math::Max(8U, _capacity);
|
||||
while (_capacity < capacity) {
|
||||
_capacity *= 2;
|
||||
}
|
||||
|
||||
@@ -315,15 +315,17 @@ rct_string_id object_get_localised_text(uint8_t** pStringTable/*ebp*/, int type/
|
||||
while (*(*pStringTable)++ != 0);
|
||||
}
|
||||
|
||||
char name[9];
|
||||
if (RCT2_GLOBAL(0x009ADAFC, uint8) == 0) {
|
||||
char name[9];
|
||||
memcpy(name, object_entry_groups[type].entries[index].name, 8);
|
||||
name[8] = 0;
|
||||
} else {
|
||||
memcpy(name, gTempObjectLoadName, 8);
|
||||
}
|
||||
name[8] = 0;
|
||||
|
||||
rct_string_id stringId = _languageCurrent->GetObjectOverrideStringId(name, tableindex);
|
||||
if (stringId != (rct_string_id)STR_NONE) {
|
||||
return stringId;
|
||||
}
|
||||
rct_string_id stringId = _languageCurrent->GetObjectOverrideStringId(name, tableindex);
|
||||
if (stringId != (rct_string_id)STR_NONE) {
|
||||
return stringId;
|
||||
}
|
||||
|
||||
// If not scenario text
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "scenario.h"
|
||||
#include "rct1.h"
|
||||
|
||||
char gTempObjectLoadName[9] = { 0 };
|
||||
|
||||
int object_load_entry(const utf8 *path, rct_object_entry *outEntry)
|
||||
{
|
||||
SDL_RWops *file;
|
||||
@@ -1566,6 +1568,7 @@ int object_get_scenario_text(rct_object_entry *entry)
|
||||
|
||||
// Tell text to be loaded into a different address
|
||||
RCT2_GLOBAL(0x009ADAFC, uint8) = 255;
|
||||
memcpy(gTempObjectLoadName, openedEntry.name, 8);
|
||||
// Not used??
|
||||
RCT2_GLOBAL(0x009ADAFD, uint8) = 1;
|
||||
object_paint(openedEntry.flags & 0x0F, 0, 0, 0, 0, (int)chunk, 0, 0);
|
||||
|
||||
@@ -91,6 +91,7 @@ typedef struct {
|
||||
} rct_object_filters;
|
||||
|
||||
extern rct_object_entry_group object_entry_groups[];
|
||||
extern char gTempObjectLoadName[9];
|
||||
|
||||
int object_load_entry(const utf8 *path, rct_object_entry *outEntry);
|
||||
void object_list_load();
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
#include "util/sawyercoding.h"
|
||||
#include "game.h"
|
||||
#include "rct1.h"
|
||||
#include "world/entrance.h"
|
||||
#include "world/footpath.h"
|
||||
#include "world/scenery.h"
|
||||
#include "world/water.h"
|
||||
|
||||
#define OBJECT_ENTRY_GROUP_COUNT 11
|
||||
#define OBJECT_ENTRY_COUNT 721
|
||||
@@ -673,6 +677,33 @@ rct_object_entry *object_list_find(rct_object_entry *entry)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rct_string_id object_get_name_string_id(rct_object_entry *entry, const void *chunk)
|
||||
{
|
||||
int objectType = entry->flags & 0x0F;
|
||||
switch (objectType) {
|
||||
case OBJECT_TYPE_RIDE:
|
||||
return ((rct_ride_type*)chunk)->name;
|
||||
case OBJECT_TYPE_SMALL_SCENERY:
|
||||
case OBJECT_TYPE_LARGE_SCENERY:
|
||||
case OBJECT_TYPE_WALLS:
|
||||
case OBJECT_TYPE_BANNERS:
|
||||
case OBJECT_TYPE_PATH_BITS:
|
||||
return ((rct_scenery_entry*)chunk)->name;
|
||||
case OBJECT_TYPE_PATHS:
|
||||
return ((rct_path_type*)chunk)->string_idx;
|
||||
case OBJECT_TYPE_SCENERY_SETS:
|
||||
return ((rct_scenery_set_entry*)chunk)->name;
|
||||
case OBJECT_TYPE_PARK_ENTRANCE:
|
||||
return ((rct_entrance_type*)chunk)->string_idx;
|
||||
case OBJECT_TYPE_WATER:
|
||||
return ((rct_water_type*)chunk)->string_idx;
|
||||
case OBJECT_TYPE_SCENARIO_TEXT:
|
||||
return ((rct_stex_entry*)chunk)->scenario_name;
|
||||
default:
|
||||
return STR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Installs an object_entry at the desired installed_entry address
|
||||
* Returns the size of the new entry. Will return 0 on failure.
|
||||
*/
|
||||
@@ -740,7 +771,12 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in
|
||||
load_object_filter(entry, chunk, filter);
|
||||
|
||||
// Always extract only the vehicle type, since the track type is always displayed in the left column, to prevent duplicate track names.
|
||||
strcpy(installed_entry_pointer, language_get_string((rct_string_id)RCT2_GLOBAL(RCT2_ADDRESS_CURR_OBJECT_BASE_STRING_ID, uint32)));
|
||||
rct_string_id nameStringId = object_get_name_string_id(entry, chunk);
|
||||
if (nameStringId == STR_NONE) {
|
||||
nameStringId = (rct_string_id)RCT2_GLOBAL(RCT2_ADDRESS_CURR_OBJECT_BASE_STRING_ID, uint32);
|
||||
}
|
||||
|
||||
strcpy(installed_entry_pointer, language_get_string(nameStringId));
|
||||
while (*installed_entry_pointer++);
|
||||
|
||||
// This is deceptive. Due to setting the total no images earlier to 0xF26E
|
||||
|
||||
Reference in New Issue
Block a user