[Scummvm-git-logs] scummvm master -> da6bc8c70a31442611875b542dfd59296fe38f7c
yuv422
noreply at scummvm.org
Sat Dec 7 11:47:45 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d2f8c673e9 NUVIE: fetch U5 savegame data for use with transfer save logic
da6bc8c70a NUVIE: fetch U4 savegame data for use with transfer save logic
Commit: d2f8c673e9ed91c2c10043729cf3f0574e7be119
https://github.com/scummvm/scummvm/commit/d2f8c673e9ed91c2c10043729cf3f0574e7be119
Author: Eric Fry (yuv422 at reversedgames.com)
Date: 2024-12-07T22:43:14+11:00
Commit Message:
NUVIE: fetch U5 savegame data for use with transfer save logic
Changed paths:
devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
engines/ultima/nuvie/save/save_game.cpp
engines/ultima/nuvie/script/script_cutscene.cpp
engines/ultima/nuvie/script/script_cutscene.h
diff --git a/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua b/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
index 23ee2124875..c00086425e1 100644
--- a/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
+++ b/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
@@ -2525,6 +2525,16 @@ local function transfer()
transferData.newSave[k] = v
end
+ if transferData.oldSave.game_type == 5 then
+ transferData.newSave.exp = math.floor(transferData.newSave.exp / 10)
+ transferData.newSave.level = 1
+ local tmpXp = math.floor(transferData.oldSave.exp / 1000)
+ while tmpXp > 0 do
+ transferData.newSave.level = transferData.newSave.level + 1
+ tmpXp = math.floor(tmpXp / 2)
+ end
+ end
+
if transfer_showStats(transferData) == false then
return false
end
@@ -2541,7 +2551,9 @@ local function transfer()
config_set("config/newgamedata/str", transferData.newSave.str)
config_set("config/newgamedata/dex", transferData.newSave.dex)
config_set("config/newgamedata/int", transferData.newSave.int)
- -- TODO add level + magic to new game
+ config_set("config/newgamedata/magic", transferData.newSave.magic)
+ config_set("config/newgamedata/exp", transferData.newSave.exp)
+ config_set("config/newgamedata/level", transferData.newSave.level)
return true
end
diff --git a/engines/ultima/nuvie/save/save_game.cpp b/engines/ultima/nuvie/save/save_game.cpp
index 617d2126791..73c896473a7 100644
--- a/engines/ultima/nuvie/save/save_game.cpp
+++ b/engines/ultima/nuvie/save/save_game.cpp
@@ -467,18 +467,22 @@ void SaveGame::update_objlist_for_new_game_u6() {
objlist.seek(0xa01);
objlist.write1(stat);
- config->value("config/newgamedata/int", stat, 0xf);
+ int intelligence;
+ config->value("config/newgamedata/int", intelligence, 0xf);
objlist.seek(0xb01);
- objlist.write1(stat);
+ objlist.write1(intelligence);
+ config->value("config/newgamedata/exp", stat, 0x172);
objlist.seek(0xc02);
- objlist.write2(0x172); // experience
+ objlist.write2(stat); // experience
+ config->value("config/newgamedata/magic", stat, intelligence * 2);
objlist.seek(0x13f2);
- objlist.write1(stat * 2); // magic
+ objlist.write1(stat); // magic
+ config->value("config/newgamedata/level", stat, 3);
objlist.seek(0xff2);
- objlist.write1(3); //level
+ objlist.write1(stat); //level
}
void SaveGame::update_objlist_for_new_game_se() {
diff --git a/engines/ultima/nuvie/script/script_cutscene.cpp b/engines/ultima/nuvie/script/script_cutscene.cpp
index 1584f0ecbc1..74db3fd86bb 100644
--- a/engines/ultima/nuvie/script/script_cutscene.cpp
+++ b/engines/ultima/nuvie/script/script_cutscene.cpp
@@ -1106,46 +1106,47 @@ static int nscript_engine_should_quit(lua_State *L) {
}
int nscript_transfer_save_game(lua_State *L) {
+ TransferSaveData saveData = cutScene->load_transfer_save();
lua_newtable(L);
lua_pushstring(L, "game_type");
- lua_pushinteger(L, 5);
+ lua_pushinteger(L, saveData.gameType);
lua_settable(L, -3);
lua_pushstring(L, "name");
- lua_pushstring(L, "Some Name");
+ lua_pushstring(L, saveData.name.c_str());
lua_settable(L, -3);
lua_pushstring(L, "gender");
- lua_pushinteger(L, 0);
+ lua_pushinteger(L, saveData.gender);
lua_settable(L, -3);
lua_pushstring(L, "class");
- lua_pushstring(L, "Avatar");
+ lua_pushstring(L, saveData.className.c_str());
lua_settable(L, -3);
lua_pushstring(L, "str");
- lua_pushinteger(L, 20);
+ lua_pushinteger(L, saveData.str);
lua_settable(L, -3);
lua_pushstring(L, "dex");
- lua_pushinteger(L, 23);
+ lua_pushinteger(L, saveData.dex);
lua_settable(L, -3);
lua_pushstring(L, "int");
- lua_pushinteger(L, 17);
+ lua_pushinteger(L, saveData.intelligence);
lua_settable(L, -3);
lua_pushstring(L, "magic");
- lua_pushinteger(L, 17);
+ lua_pushinteger(L, saveData.magic);
lua_settable(L, -3);
lua_pushstring(L, "exp");
- lua_pushinteger(L, 250);
+ lua_pushinteger(L, saveData.exp);
lua_settable(L, -3);
lua_pushstring(L, "level");
- lua_pushinteger(L, 8);
+ lua_pushinteger(L, saveData.level);
lua_settable(L, -3);
return 1;
@@ -1426,6 +1427,28 @@ Std::vector<CSMidGameData> ScriptCutscene::load_midgame_file(const char *filenam
return v;
}
+TransferSaveData ScriptCutscene::load_transfer_save() {
+ TransferSaveData data;
+ data.gameType = 0;
+ data.name = "";
+ data.gender = 0;
+ data.className = "Avatar";
+ data.str = 0;
+ data.dex = 0;
+ data.intelligence = 0;
+ data.magic = 0;
+ data.exp = 0;
+ data.level = 0;
+
+ if (load_u5_save_file(data)) {
+ return data;
+ }
+
+ // TODO load U4 file here.
+
+ return data;
+}
+
Std::vector<Std::string> ScriptCutscene::load_text(const char *filename, uint8 idx) {
Common::Path path;
U6Lib_n lib_n;
@@ -1755,6 +1778,39 @@ int ScriptCutscene::display_wrapped_text_line(Std::string str, uint8 text_color,
return y;
}
+
+bool ScriptCutscene::load_u5_save_file(TransferSaveData &saveData) {
+ NuvieIOFileRead file;
+ Common::Path filename;
+ char name[9];
+
+ config_get_path(config, "saved.gam", filename);
+
+ if (file.open(filename) == false) {
+ return false;
+ }
+
+ saveData.gameType = 5;
+
+ file.seek(2);
+ file.readToBuf((unsigned char *)name, 9);
+ saveData.name = Common::String(name);
+ saveData.gender = file.read1() == 0xc ? 0 : 1;
+ file.read1(); // class
+ file.read1(); // status
+ saveData.str = file.read1();
+ saveData.dex = file.read1();
+ saveData.intelligence = file.read1();
+ saveData.magic = file.read1();
+ file.seek(0x16);
+ saveData.exp = file.read2();
+ saveData.level = file.read1();
+
+ file.close();
+
+ return true;
+}
+
void CSImage::setScale(uint16 percentage) {
if (scale == percentage) {
return;
diff --git a/engines/ultima/nuvie/script/script_cutscene.h b/engines/ultima/nuvie/script/script_cutscene.h
index 5da4baf64e3..c1d7dbcb643 100644
--- a/engines/ultima/nuvie/script/script_cutscene.h
+++ b/engines/ultima/nuvie/script/script_cutscene.h
@@ -109,6 +109,19 @@ struct CSMidGameData {
Std::vector<CSImage *> images;
};
+struct TransferSaveData {
+ int gameType;
+ Common::String name;
+ int gender;
+ Common::String className;
+ int str;
+ int dex;
+ int intelligence;
+ int magic;
+ int exp;
+ int level;
+};
+
void nscript_init_cutscene(lua_State *L, Configuration *cfg, GUI *gui, SoundManager *sm);
class ScriptCutscene : public GUI_Widget {
@@ -138,6 +151,8 @@ public:
Std::vector<CSMidGameData> load_midgame_file(const char *filename);
+ TransferSaveData load_transfer_save();
+
CSImage *load_image(const char *filename, int idx, int sub_idx = 0);
Std::vector<Std::vector<CSImage *> > load_all_images(const char *filename);
void add_sprite(CSSprite *s) {
@@ -205,6 +220,8 @@ private:
CSImage *load_image_from_lzc(const Common::Path &filename, uint16 idx, uint16 sub_idx);
void display_wrapped_text(CSSprite *s);
int display_wrapped_text_line(Std::string str, uint8 text_color, int x, int y, uint8 align_val);
+
+ bool load_u5_save_file(TransferSaveData &saveData);
};
ScriptCutscene *get_cutscene();
Commit: da6bc8c70a31442611875b542dfd59296fe38f7c
https://github.com/scummvm/scummvm/commit/da6bc8c70a31442611875b542dfd59296fe38f7c
Author: Eric Fry (yuv422 at reversedgames.com)
Date: 2024-12-07T22:43:14+11:00
Commit Message:
NUVIE: fetch U4 savegame data for use with transfer save logic
Changed paths:
devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
engines/ultima/nuvie/script/script_cutscene.cpp
engines/ultima/nuvie/script/script_cutscene.h
diff --git a/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua b/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
index c00086425e1..0c8865fee53 100644
--- a/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
+++ b/devtools/create_ultima/files/ultima6/scripts/u6/intro.lua
@@ -1,7 +1,7 @@
-SDLK_UP = 82 + 1073741824
-SDLK_DOWN = 81 + 1073741824
-SDLK_RIGHT = 79 + 1073741824
-SDLK_LEFT = 80 + 1073741824
+SDLK_UP = 273
+SDLK_DOWN = 274
+SDLK_RIGHT = 275
+SDLK_LEFT = 276
g_img_tbl = {}
@@ -2511,6 +2511,34 @@ local function transfer_portrait(transferData)
return not exiting
end
+local function update_u4_stat(stat)
+ if stat > 9 then
+ if stat < 30 then
+ stat = math.floor((stat - 9) / 2) + 10
+ else
+ stat = math.floor((stat - 30) / 4) + 20
+ end
+ end
+ return stat
+end
+
+local function transfer_no_save_found()
+ load_images("vellum1.shp")
+ local bg = sprite_new(g_img_tbl[0], 0x10, 0x50, true)
+
+ centre_string(bg.image, "TRANSFER A CHARACTER", 9, 0x3d)
+ image_draw_line(bg.image, 9, 18, 274, 18, 0x3d)
+
+ centre_string(bg.image, "No character found! If you wish to", 40, 0x3d)
+ centre_string(bg.image, "transfer a character from a hard disk", 40 + 9, 0x3d)
+ centre_string(bg.image, "please copy either SAVED.GAM or PARTY.SAV", 40 + 18, 0x3d)
+ centre_string(bg.image, "into your Ultima VI game directory.", 40 + 27, 0x3d)
+
+ wait_for_input()
+
+ bg.visible = false
+end
+
local function transfer()
if transfer_page1() == false then
return false
@@ -2525,14 +2553,23 @@ local function transfer()
transferData.newSave[k] = v
end
- if transferData.oldSave.game_type == 5 then
- transferData.newSave.exp = math.floor(transferData.newSave.exp / 10)
- transferData.newSave.level = 1
- local tmpXp = math.floor(transferData.oldSave.exp / 1000)
- while tmpXp > 0 do
- transferData.newSave.level = transferData.newSave.level + 1
- tmpXp = math.floor(tmpXp / 2)
- end
+ if transferData.oldSave.game_type == 0 then
+ transfer_no_save_found()
+ return false
+ end
+
+ if transferData.oldSave.game_type == 4 then
+ transferData.newSave.str = update_u4_stat(transferData.newSave.str)
+ transferData.newSave.dex = update_u4_stat(transferData.newSave.dex)
+ transferData.newSave.int = update_u4_stat(transferData.newSave.int)
+ end
+ transferData.newSave.magic = transferData.newSave.int
+ transferData.newSave.exp = math.floor(transferData.newSave.exp / 10)
+ transferData.newSave.level = 1
+ local tmpXp = math.floor(transferData.oldSave.exp / 1000)
+ while tmpXp > 0 do
+ transferData.newSave.level = transferData.newSave.level + 1
+ tmpXp = math.floor(tmpXp / 2)
end
if transfer_showStats(transferData) == false then
@@ -3474,7 +3511,10 @@ local function main_menu()
return "J"
end
elseif y > 127 and y < 149 then
- --transfer a character
+ if selected_transfer() == true then
+ intro()
+ return "J"
+ end
elseif y > 148 and y < 170 then
selected_acknowledgments()
elseif y > 169 and y < 196 then
diff --git a/engines/ultima/nuvie/script/script_cutscene.cpp b/engines/ultima/nuvie/script/script_cutscene.cpp
index 74db3fd86bb..79cf237c875 100644
--- a/engines/ultima/nuvie/script/script_cutscene.cpp
+++ b/engines/ultima/nuvie/script/script_cutscene.cpp
@@ -1444,7 +1444,7 @@ TransferSaveData ScriptCutscene::load_transfer_save() {
return data;
}
- // TODO load U4 file here.
+ load_u4_save_file(data);
return data;
}
@@ -1779,6 +1779,48 @@ int ScriptCutscene::display_wrapped_text_line(Std::string str, uint8 text_color,
return y;
}
+static constexpr char u4ClassNameTbl[9][9] = {
+ "Mage",
+ "Bard",
+ "Fighter",
+ "Druid",
+ "Tinker",
+ "Paladin",
+ "Ranger",
+ "Shepherd",
+ "Avatar",
+};
+
+bool ScriptCutscene::load_u4_save_file(TransferSaveData &saveData) {
+ NuvieIOFileRead file;
+ Common::Path filename;
+ char name[16];
+
+ config_get_path(config, "party.sav", filename);
+
+ if (file.open(filename) == false) {
+ return false;
+ }
+
+ saveData.gameType = 4;
+ file.seek(10);
+ saveData.level = file.read2() / 100;
+ saveData.exp = file.read2();
+ saveData.str = file.read2();
+ saveData.dex = file.read2();
+ saveData.intelligence = file.read2();
+ saveData.magic = file.read2();
+ file.seek(28);
+ file.readToBuf((unsigned char *)name, 16);
+ saveData.name = Common::String(name).substr(0, 8);
+ saveData.gender = file.read1() == 0xc ? 0 : 1;
+ int classId = file.read1();
+ if (classId < 9) {
+ saveData.className = Common::String(u4ClassNameTbl[classId]);
+ }
+ return true;
+}
+
bool ScriptCutscene::load_u5_save_file(TransferSaveData &saveData) {
NuvieIOFileRead file;
Common::Path filename;
diff --git a/engines/ultima/nuvie/script/script_cutscene.h b/engines/ultima/nuvie/script/script_cutscene.h
index c1d7dbcb643..448c61ca708 100644
--- a/engines/ultima/nuvie/script/script_cutscene.h
+++ b/engines/ultima/nuvie/script/script_cutscene.h
@@ -221,6 +221,7 @@ private:
void display_wrapped_text(CSSprite *s);
int display_wrapped_text_line(Std::string str, uint8 text_color, int x, int y, uint8 align_val);
+ bool load_u4_save_file(TransferSaveData &saveData);
bool load_u5_save_file(TransferSaveData &saveData);
};
More information about the Scummvm-git-logs
mailing list