CnCNet / yrpp-spawner

CnCNet DLL for Command and Conquer: Yuri's Revenge using Syringe
GNU General Public License v3.0
21 stars 13 forks source link

Feature request: add "CustomMissionID" for saved games #18

Open SadPencil opened 7 months ago

SadPencil commented 7 months ago

A .sav file is an OLE document that can be considered as a "dictionary". For example, the OLE key Scenario Description refers to a UTF-16 LE string corresponds to the title of a saved game file.

I am currently working on a feature to let xna-cncnet-client support loading custom missions. In order to support this feature, xna-cncnet-client must have a way to identify which mission corresponds to a saved game file, along with other restrictions to prevent user loads a different mission (to prevent potential conflicts; as supplemental files are copied by the client)

Thus, I request an addtional data field, described as below.

CustomMissionID

This value will be specified via the spawn.ini file, given when the spawner is launchered.

; Generated by DTA Client
[Settings]
Scenario=spawnmap.ini
CustomMissionID=12345678
IsSinglePlayer=Yes

CustomMissionID is an int32 integer. If this value is omitted, consider it 0.

In a .sav file, the OLE key CustomMissionID should corresponds with 4 byte-values that contains such an int32 integer in little-endian order. The number is untouched, saved as-is.

Rename of missionmd.ini file

When CustomMissionID is specified and not 0, the access of missionmd.ini shall be redirct to spawn.ini file. This enables the client automatically generates the corresponding mission info without interrupting the game.

Full example of a spawn.ini file:

; Generated by CnCNet Client

[Settings]
Scenario=Maps\CustomMissions\vnsepa.map
GameSpeed=1
Ra2Mode=False
CustomLoadScreen=Resources/l600s02.pcx
IsSinglePlayer=Yes
SidebarHack=False
Side=0
BuildOffAlly=True
DifficultyModeHuman=0
DifficultyModeComputer=2
CustomMissionID=-715243874

[Maps\CustomMissions\vnsepa.map]
Briefing=Brief:AREDDAWN
ShowBriefing=true
UIName=MAP:TITREDDAWN
LSLoadMessage=LoadMsg:AREDDAWN
LSLoadBriefing=LoadBrief:AREDDAWN
LS640BriefLocX=20
LS640BriefLocY=20
LS800BriefLocX=20
LS800BriefLocY=20
LS640BkgdName=custommission.shp
LS800BkgdName=custommission.shp
LS800BkgdPal=custommission.pal
LoadScreenText.Color=LightGrey

Saved games list filter

When CustomMissionID is specified and it is not 0, only saved game files with the same CustomMissionID shall be displayed.

Otherwise, when CustomMissionID is not specified or is 0, only saved game files without CustomMissionID or with a zero-valued CustomMissionID shall be displayed.

Reading CustomMissionID from saved game file

When loading a saved game, the spawner loads CustomMissionID based on the OLE key CustomMissionID in a .sav file. CustomMissionID will not be specified in spawn.ini in this case.

SadPencil commented 7 months ago

@Belonit

In https://github.com/CnCNet/cncnet-yr-client-package/pull/288 you said "At the moment, the client does not have a mechanism for processing saves from different game modes."

.sav file is an OLE document, which means the spawner is able to deliver arbitrary information from the client to save files (e.g., PR #19), for example, the game mode number. The client is then able to read these additional information (it does not require much time to implement) from the save files, and does whatever needs to be done based on these information.

This design should be better than the current workaround.

Belonit commented 7 months ago

@Belonit

In CnCNet/cncnet-yr-client-package#288 you said "At the moment, the client does not have a mechanism for processing saves from different game modes."

.sav file is an OLE document, which means the spawner is able to deliver arbitrary information from the client to save files (e.g., PR #19), for example, the game mode number. The client is then able to read these additional information (it does not require much time to implement) from the save files, and does whatever needs to be done based on these information.

This design should be better than the current workaround.

This is already contained in the .sav file. image

Belonit commented 6 months ago

To let identify which mission corresponds to a saved game file, I request an addtional data field, described as below.xna-cncnet-client

@SadPencil Maybe it's worth using the meta information that already exists? It seems to me that it is quite enough: Campaign - indicates the campaign index Scenario number - indicates the scenario index Version - indicates the unique identifier of the mod Internal Version - indicates the unique identifier of the engine (including Ares and Phobos)

What really needs to be done is to force the spawner to correctly write the Campaign and Scenario number fields.

SadPencil commented 6 months ago

To let identify which mission corresponds to a saved game file, I request an addtional data field, described as below.xna-cncnet-client

@SadPencil Maybe it's worth using the meta information that already exists? It seems to me that it is quite enough: Campaign - indicates the campaign index Scenario number - indicates the scenario index Version - indicates the unique identifier of the mod Internal Version - indicates the unique identifier of the engine (including Ares and Phobos)

What really needs to be done is to force the spawner to correctly write the Campaign and Scenario number fields.

According to @chaserli 's investigation, Scenario number seems to be used in game, and I don't know if it is safe to use this field.

Besides, now I start questioning what should happen if a player wins a campaign and then the next campaign starts. Should the Scenario number increase itself by 1? In original RA2/YR, Scenario number will be increased by 1 on next mission, and correctly loaded when user loads a saved game from in-game menu.