Skip to content

Commit dfdeeab

Browse files
committed
Split no-spawn-argument error check from spawner code so it can be used in Vinifera spawner builds
1 parent 666c9f3 commit dfdeeab

3 files changed

Lines changed: 71 additions & 74 deletions

File tree

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ endif
535535
# =========================================================
536536
ifdef TSCLIENT
537537
OBJS += src/ts_hacks.o
538+
OBJS += src/spawn_arg_check.o
538539
endif
539540
ifdef TIBSUN
540541
OBJS += src/ts_hacks.o
@@ -544,24 +545,31 @@ ifdef SINGLEPLAYER
544545
endif
545546
ifdef MOD_DTA
546547
OBJS += src/dta_hacks.o
548+
OBJS += src/spawn_arg_check.o
547549
endif
548550
ifdef MOD_TI
549551
OBJS += src/ti_hacks.o
552+
OBJS += src/spawn_arg_check.o
550553
endif
551554
ifdef MOD_TO
552555
OBJS += src/to_hacks.o
556+
OBJS += src/spawn_arg_check.o
553557
endif
554558
ifdef MOD_RUBICON
555559
OBJS += src/rubicon_hacks.o
560+
OBJS += src/spawn_arg_check.o
556561
endif
557562
ifdef MOD_FD
558563
OBJS += src/fd_hacks.o
564+
OBJS += src/spawn_arg_check.o
559565
endif
560566
ifdef MOD_SD
561567
OBJS += src/sd_hacks.o
568+
OBJS += src/spawn_arg_check.o
562569
endif
563570
ifdef MOD_TSA
564571
OBJS += src/tsa_hacks.o
572+
OBJS += src/spawn_arg_check.o
565573
endif
566574

567575

src/spawn_arg_check.asm

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
%include "macros/patch.inc"
2+
%include "macros/datatypes.inc"
3+
%include "TiberianSun.inc"
4+
%include "patch.inc"
5+
6+
; Displays an error message to the user if the -SPAWN argument has not been provided.
7+
8+
section .bss
9+
SpawnArgFound RESD 1
10+
11+
section .rdata
12+
str_SpawnArg db "-SPAWN",0
13+
14+
%ifdef MOD_DTA
15+
str_GameNameTitle db "Dawn of the Tiberium Age",0
16+
str_PleaseRunClient db "Please run DTA.exe instead.",0
17+
%elifdef MOD_TI
18+
str_GameNameTitle db "Twisted Insurrection",0
19+
str_PleaseRunClient db "Please run TwistedInsurrection.exe instead.",0
20+
%elifdef MOD_TO
21+
str_GameNameTitle db "Tiberian Odyssey",0
22+
str_PleaseRunClient db "Please run TiberianOdyssey.exe instead.",0
23+
%elifdef MOD_RUBICON
24+
str_GameNameTitle db "Rubicon",0
25+
str_PleaseRunClient db "Please run Rubicon.exe instead.",0
26+
%elifdef TSCLIENT
27+
str_GameNameTitle db "Tiberian Sun",0
28+
str_PleaseRunClient db "Please run TiberianSun.exe instead.",0
29+
%else
30+
str_GameNameTitle db "Tiberian Sun",0
31+
str_PleaseRunClient db "Please run the game client instead.",0
32+
%endif
33+
34+
hack 0x005FFDBF
35+
pushad
36+
37+
call [_imp__GetCommandLineA]
38+
push str_SpawnArg
39+
push eax
40+
call stristr_
41+
add esp, 8
42+
xor ebx, ebx
43+
cmp eax, 0
44+
setne bl
45+
mov [SpawnArgFound], ebx
46+
popad
47+
48+
cmp dword [SpawnArgFound], 1
49+
je .Normal_Code
50+
51+
; -SPAWN arg not found, display error message asking to run the client instead
52+
53+
push 16 ; uType
54+
push str_GameNameTitle ; Title
55+
push str_PleaseRunClient ; Text
56+
push 0 ; hWnd
57+
call [0x006CA458] ; ds:MessageBoxA
58+
jmp 0x005FFCB0
59+
60+
.Normal_Code:
61+
call 0x00472540 ; Init_Language
62+
jmp 0x005FFDC4

src/spawner/spawner.asm

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ cextern SharedControl
4949
@LJMP 0x004BDDB1, _HouseClass__Make_Ally_STFU_when_Allying_In_Loading_Screen_Spawner
5050
@LJMP 0x004E078C, _Init_Game_Check_Spawn_Arg_No_Intro
5151

52-
@LJMP 0x005FFDBF, _WinMain_Read_Check_Spawn_Arg
53-
5452
; Inside HouseClass::Mplayer_Defeated skip some checks which makes game continue
5553
; even if there are only allied AI players left, in skirmish
5654
@LJMP 0x004BF7B6, 0x004BF7BF
@@ -88,7 +86,6 @@ section .bss
8886
inet_addr RESD 1
8987

9088
IsDoingAlliancesSpawner RESB 1
91-
IsSpawnArgPresent RESD 1
9289
AllyBySpawnLocation RESD 1
9390

9491
HouseColorsArray RESD 8
@@ -191,20 +188,6 @@ section .rdata
191188
str_AutoSurrender db "AutoSurrender",0
192189
str_GameNameTitle db "Tiberian Sun",0
193190

194-
%ifdef MOD_DTA
195-
str_PleaseRunClient db "Please run DTA.exe instead.",0
196-
%elifdef MOD_TI
197-
str_PleaseRunClient db "Please run TwistedInsurrection.exe instead.",0
198-
%elifdef MOD_TO
199-
str_PleaseRunClient db "Please run TiberianOdyssey.exe instead.",0
200-
%elifdef MOD_RUBICON
201-
str_PleaseRunClient db "Please run Rubicon.exe instead.",0
202-
%elifdef TSCLIENT
203-
str_PleaseRunClient db "Please run TiberianSun.exe instead.",0
204-
%else
205-
str_PleaseRunClient db "Please run the game client instead.",0
206-
%endif
207-
208191
str_CampaignID db "CampaignID",0
209192
str_UseMPAIBaseNodes db "UseMPAIBaseNodes", 0
210193
str_PlayMoviesInMultiplayer db "PlayMoviesInMultiplayer",0
@@ -295,9 +278,6 @@ section .rdata
295278
section .text
296279

297280
_Read_Scenario_INI_Fix_Spawner_DifficultyMode_Setting:
298-
cmp dword [IsSpawnArgPresent], 0
299-
jz .Ret
300-
301281
cmp dword [SessionType], 0
302282
jnz .Ret
303283

@@ -450,16 +430,8 @@ _Read_Scenario_INI_Dont_Create_Units_Earlier_Dont_Create_Twice:
450430
jmp 0x005DDEF8
451431

452432
_HouseClass__Computer_Paranoid_Disable_With_Spawner:
453-
cmp dword [IsSpawnArgPresent], 1
454-
jz .Ret
455-
456-
.Normal_Code:
457-
mov ecx, [HouseClassArray_Count]
458-
jmp 0x004C3636
459-
460-
.Ret:
461433
jmp 0x004C3700 ; jump to RETN instruction
462-
434+
463435
_Assign_Houses_Human_Countries:
464436
mov ebp, [HouseClassArray_Count]
465437
cmp dword [HouseCountriesArray+ebp*4], -1
@@ -555,45 +527,9 @@ _HouseClass__AI_Attack_Stuff_Alliance_Check:
555527
jmp 0x004C06F7
556528

557529
_sub_5ED470_Dont_Read_Scenario_Descriptions_When_Spawner_Active:
558-
cmp dword [IsSpawnArgPresent], 1
559-
jz .Ret
560-
561-
call SessionClass__Read_Scenario_Descriptions
562-
563-
.Ret:
564530
call [_imp__timeGetTime]
565531
jmp 0x005ED482
566532

567-
_WinMain_Read_Check_Spawn_Arg:
568-
pushad
569-
570-
call [_imp__GetCommandLineA]
571-
push str_SpawnArg
572-
push eax
573-
call stristr_
574-
add esp, 8
575-
xor ebx, ebx
576-
cmp eax, 0
577-
setne bl
578-
mov [IsSpawnArgPresent], ebx
579-
popad
580-
581-
cmp dword [IsSpawnArgPresent], 1
582-
je .Normal_Code
583-
584-
; -SPAWN arg not found, display error message asking to run the client instead
585-
586-
push 16 ; uType
587-
push str_GameNameTitle ; Title
588-
push str_PleaseRunClient ; Text
589-
push 0 ; hWnd
590-
call [0x006CA458] ; ds:MessageBoxA
591-
jmp 0x005FFCB0
592-
593-
.Normal_Code:
594-
call 0x00472540 ; Init_Language
595-
jmp 0x005FFDC4
596-
597533
Init_Game_Spawner:
598534
lea eax, [UsedSpawnsArray]
599535
push 32 ; Size
@@ -611,13 +547,8 @@ _Init_Game_Check_Spawn_Arg_No_Intro:
611547

612548
popad
613549

614-
cmp dword [IsSpawnArgPresent], 0
615-
jz .Normal_Code
616-
617-
.No_Intro:
618550
jmp 0x004E0848
619551

620-
621552
.Normal_Code:
622553
and ecx, 4
623554
cmp cl, 4
@@ -1131,10 +1062,6 @@ Initialize_Spawn:
11311062

11321063
%define TempBuf ebp-128
11331064

1134-
1135-
cmp dword [IsSpawnArgPresent], 0
1136-
je .Exit_Error
1137-
11381065
cmp dword [SpawnerActive], 1
11391066
jz .Ret_Exit
11401067

0 commit comments

Comments
 (0)