Skip to content

Commit 34d08ca

Browse files
committed
Overlay: add course editor window
1 parent 9a6f795 commit 34d08ca

File tree

9 files changed

+458
-16
lines changed

9 files changed

+458
-16
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ set(outrun2006tweaks_SOURCES
196196
"src/hooks_misc.cpp"
197197
"src/hooks_textures.cpp"
198198
"src/hooks_uiscaling.cpp"
199+
"src/overlay/course_editor.cpp"
199200
"src/overlay/hooks_overlay.cpp"
200201
"src/overlay/notifications.hpp"
201202
"src/overlay/overlay.cpp"

OutRun2006Tweaks.lods.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#
77
# Please post any bad objects you find to https://github.com/emoose/OutRun2006Tweaks/issues/97!
88

9+
# PALM BEACH
10+
[Stage 0]
11+
# Bad geo when entering from left-side bunki
12+
0x1 = 0xD
13+
914
# ALPINE
1015
[Stage 3]
1116
# See-through mountains in distance from bunki
@@ -31,7 +36,13 @@
3136

3237
# MAYA
3338
[Stage 25]
39+
# Tree sprite on bunki transition
40+
0x1 = 0x34
41+
# Floating temple over entrance
3442
0x1 = 0x34
43+
0x2 = 0x2B8, 0x2B9, 0x2BB, 0x2BC, 0x2BE, 0x2D9, 0x2DB
44+
0x3 = 0x2
45+
0x4 = 0x24
3546

3647
# NEW YORK
3748
[Stage 26]
@@ -44,3 +55,8 @@
4455
[Stage 60]
4556
# Bad polygon when entering from bunki
4657
0x1 = 0x6
58+
59+
# BEACH (BR)
60+
[Stage 65]
61+
# Bad polygon when entering from bunki
62+
0x1 = 0x27

src/game.hpp

Lines changed: 142 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,104 @@ enum GameState
121121
STATE_SUMOREWARD = 0x24,
122122
};
123123

124+
enum GameStage : int
125+
{
126+
STAGE_PALM_BEACH,
127+
STAGE_DEEP_LAKE,
128+
STAGE_INDUSTRIAL_COMPLEX,
129+
STAGE_ALPINE,
130+
STAGE_SNOW_MOUNTAIN,
131+
STAGE_CLOUDY_HIGHLAND,
132+
STAGE_CASTLE_WALL,
133+
STAGE_GHOST_FOREST,
134+
STAGE_CONIFEROUS_FOREST,
135+
STAGE_DESERT,
136+
STAGE_TULIP_GARDEN,
137+
STAGE_METROPOLIS,
138+
STAGE_ANCIENT_RUINS,
139+
STAGE_CAPE_WAY,
140+
STAGE_IMPERIAL_AVENUE,
141+
STAGE_BEACH,
142+
STAGE_SEQUOIA,
143+
STAGE_NIAGARA,
144+
STAGE_LAS_VEGAS,
145+
STAGE_ALASKA,
146+
STAGE_GRAND_CANYON,
147+
STAGE_SAN_FRANCISCO,
148+
STAGE_AMAZON,
149+
STAGE_MACHU_PICCHU,
150+
STAGE_YOSEMITE,
151+
STAGE_MAYA,
152+
STAGE_NEW_YORK,
153+
STAGE_PRINCE_EDWARD,
154+
STAGE_FLORIDA,
155+
STAGE_EASTER_ISLAND,
156+
STAGE_PALM_BEACH_R,
157+
STAGE_DEEP_LAKE_R,
158+
STAGE_INDUSTRIAL_COMPLEX_R,
159+
STAGE_ALPINE_R,
160+
STAGE_SNOW_MOUNTAIN_R,
161+
STAGE_CLOUDY_HIGHLAND_R,
162+
STAGE_CASTLE_WALL_R,
163+
STAGE_GHOST_FOREST_R,
164+
STAGE_CONIFEROUS_FOREST_R,
165+
STAGE_DESERT_R,
166+
STAGE_TULIP_GARDEN_R,
167+
STAGE_METROPOLIS_R,
168+
STAGE_ANCIENT_RUINS_R,
169+
STAGE_CAPE_WAY_R,
170+
STAGE_IMPERIAL_AVENUE_R,
171+
STAGE_BEACH_R,
172+
STAGE_SEQUOIA_R,
173+
STAGE_NIAGARA_R,
174+
STAGE_LAS_VEGAS_R,
175+
STAGE_ALASKA_R,
176+
STAGE_GRAND_CANYON_R,
177+
STAGE_SAN_FRANCISCO_R,
178+
STAGE_AMAZON_R,
179+
STAGE_MACHU_PICCHU_R,
180+
STAGE_YOSEMITE_R,
181+
STAGE_MAYA_R,
182+
STAGE_NEW_YORK_R,
183+
STAGE_PRINCE_EDWARD_R,
184+
STAGE_FLORIDA_R,
185+
STAGE_EASTER_ISLAND_R,
186+
STAGE_PALM_BEACH_T,
187+
STAGE_BEACH_T,
188+
STAGE_PALM_BEACH_BT,
189+
STAGE_BEACH_BT,
190+
STAGE_PALM_BEACH_BR,
191+
STAGE_BEACH_BR
192+
};
193+
static_assert(sizeof(GameStage) == 4);
194+
195+
struct TAG_model_info
196+
{
197+
uint8_t todo[0x98];
198+
};
199+
static_assert(sizeof(TAG_model_info) == 0x98);
200+
201+
struct StageTable_mb
202+
{
203+
GameStage StageUniqueName_0;
204+
int StageTableIdx_4;
205+
uint32_t field_8;
206+
uint32_t field_C;
207+
int ExtendedTime_10;
208+
TAG_model_info* CsInfoPtr_14;
209+
TAG_model_info* BrInfoPtr_18;
210+
int CsInfoId_1C;
211+
int BrInfoId_20;
212+
int ExitTableIdx_24[2];
213+
int ExitIDs_2C[2];
214+
uint8_t gap34[48];
215+
struct tagOthcarPercentTable* OthcarPercentTablePtr_64;
216+
void* OthcarPercentTablePtr_68;
217+
uint32_t field_6C;
218+
uint32_t field_70;
219+
uint32_t field_74;
220+
};
221+
124222
enum ChrSet
125223
{
126224
CHR_AUT01 = 0,
@@ -500,6 +598,8 @@ typedef struct tagEVWORK_CAR
500598
float field_10DC;
501599
float field_10E0;
502600
uint8_t unk_10E4[12];
601+
602+
inline bool is_in_bunki() { return OnRoadPlace_5C.loadColiType_0 != 0; }
503603
} EVWORK_CAR;
504604
static_assert(sizeof(EVWORK_CAR) == 0x10F0);
505605
// car0 = 0x7804B0
@@ -632,11 +732,48 @@ typedef struct TDrawBuffer
632732
} DrawBuffer;
633733
static_assert(sizeof(DrawBuffer) == 0x1C);
634734

635-
inline void WaitForDebugger()
735+
struct SumoNet_MatchMakingInfo
636736
{
637-
#ifdef _DEBUG
638-
while (!IsDebuggerPresent())
737+
uint32_t SlotCount_0;
738+
uint32_t SlotCount_4;
739+
int SlotCount_8;
740+
int SlotCount_C;
741+
char unk_field_24_10;
742+
uint8_t unk_11[3];
743+
uint32_t MatchType_14;
744+
uint32_t Nationality_18;
745+
uint32_t unk_field_54_1C;
746+
uint32_t unk_field_58_20;
747+
uint32_t CourseType_24;
748+
uint32_t Course_28;
749+
uint32_t unk_field_64_2C;
750+
uint32_t CarClass_30;
751+
uint32_t CarType_34;
752+
uint32_t CatchUp_38;
753+
uint32_t unk_field_74_3C;
754+
uint32_t Collision_40;
755+
uint32_t unk_field_7C_44;
756+
char LobbyName_48[16];
757+
};
758+
static_assert(sizeof(SumoNet_MatchMakingInfo) == 0x58);
759+
760+
struct SumoNet_NetDriver
761+
{
762+
uint32_t vftable;
763+
uint8_t unk_4;
764+
uint8_t is_hosting_5;
765+
uint8_t unk_6;
766+
uint8_t is_online_7;
767+
768+
inline bool is_online_driver()
639769
{
770+
// some other drivers seem to be for lan/online/etc
771+
// TODO: should probably use Module::exe_ptr here, but it's not included atm..
772+
return vftable == 0x627EB8;
640773
}
641-
#endif
642-
}
774+
775+
inline bool is_hosting_online()
776+
{
777+
return is_online_driver() && is_hosting_5 && is_online_7;
778+
}
779+
};

src/game_addrs.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace Game
5151
inline int* app_time = nullptr; // used by SetTweeningTable etc
5252
inline int* sprani_num_ticks = nullptr; // number of game ticks being ran in the current frame (can be 0 if above 60FPS)
5353

54-
inline int* stg_stage_num = nullptr;
54+
inline GameStage* stg_stage_num = nullptr;
5555

5656
inline D3DXVECTOR2* screen_scale = nullptr;
5757

@@ -102,6 +102,8 @@ namespace Game
102102
inline fn_stdcall_1arg_int Sumo_CheckRacerUnlocked = nullptr;
103103

104104
inline const char* SumoNet_OnlineUserName = nullptr;
105+
inline SumoNet_MatchMakingInfo* SumoNet_LobbyInfo = nullptr;
106+
inline SumoNet_NetDriver** SumoNet_CurNetDriver = nullptr;
105107

106108
// 2d sprite drawing
107109
inline fn_1arg sprSetFontPriority = nullptr;
@@ -179,7 +181,7 @@ namespace Game
179181
app_time = Module::exe_ptr<int>(0x49EDB8);
180182
sprani_num_ticks = Module::exe_ptr<int>(0x380278);
181183

182-
stg_stage_num = Module::exe_ptr<int>(0x3D2E8C);
184+
stg_stage_num = Module::exe_ptr<GameStage>(0x3D2E8C);
183185

184186
screen_scale = Module::exe_ptr<D3DXVECTOR2>(0x340C94);
185187

@@ -228,6 +230,8 @@ namespace Game
228230
Sumo_CheckRacerUnlocked = Module::fn_ptr<fn_stdcall_1arg_int>(0xE8410);
229231

230232
SumoNet_OnlineUserName = Module::exe_ptr<const char>(0x430C20);
233+
SumoNet_LobbyInfo = Module::exe_ptr<SumoNet_MatchMakingInfo>(0x37FF90);
234+
SumoNet_CurNetDriver = Module::exe_ptr<SumoNet_NetDriver*>(0x3D68AC);
231235

232236
sprSetFontPriority = Module::fn_ptr<fn_1arg>(0x2CCB0);
233237
sprSetPrintFont = Module::fn_ptr<fn_1arg>(0x2CA60);

src/hooks_drawdistance.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void DrawDist_DrawOverlay()
5656
return;
5757
}
5858

59-
int cur_stage_num = *Game::stg_stage_num;
59+
GameStage cur_stage_num = *Game::stg_stage_num;
6060
const char* cur_stage_name = Game::GetStageUniqueName(cur_stage_num);
6161
auto& objectExclusions = ObjectExclusionsPerStage[cur_stage_num];
6262

@@ -159,7 +159,7 @@ void DrawDist_DrawOverlay()
159159
}
160160
}
161161
if (!clipboard.empty())
162-
clipboard = std::format("# {}\n[Stage {}]{}", cur_stage_name, cur_stage_num, clipboard);
162+
clipboard = std::format("# {}\n[Stage {}]{}", cur_stage_name, int(cur_stage_num), clipboard);
163163

164164
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, clipboard.length() + 1);
165165
if (hMem)
@@ -390,7 +390,7 @@ class DrawDistanceIncrease : public Hook
390390
{
391391
// CANYON: when cur section is lower than 30 (car inside bunki), limit draw dist to ~80
392392
// prevents some far-off stage parts drawing in the air
393-
if (*Game::stg_stage_num == 20 /* CANYON */ && CsLengthNum < 30)
393+
if (*Game::stg_stage_num == STAGE_GRAND_CANYON && CsLengthNum < 30)
394394
maxDrawDistance = min(maxDrawDistance, 80);
395395
}
396396

0 commit comments

Comments
 (0)