src/depot: add, move file loads to depot resolution

master
q3k 2021-04-28 20:18:44 +02:00
parent 5f36ee14ed
commit 7680c942a5
33 changed files with 487 additions and 305 deletions

View File

@ -4,6 +4,37 @@ workspace(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/bcc11a8918f8cc9b43c9a0dc5da7b52d48452bd3.zip"],
strip_prefix = "abseil-cpp-bcc11a8918f8cc9b43c9a0dc5da7b52d48452bd3",
sha256 = "3a812487dc353d2322c8728cca2233d403fbb72c75308c4d455bb742fca7a6ec"
)
http_archive(
name = "com_google_googletest",
# Keep this URL in sync with ABSL_GOOGLETEST_COMMIT in ci/cmake_common.sh.
urls = ["https://github.com/google/googletest/archive/8567b09290fe402cf01923e2131c5635b8ed851b.zip"], # 2020-06-12T22:24:28Z
strip_prefix = "googletest-8567b09290fe402cf01923e2131c5635b8ed851b",
sha256 = "9a8a166eb6a56c7b3d7b19dc2c946fe4778fd6f21c7a12368ad3b836d8f1be48",
)
http_archive(
name = "com_github_google_benchmark",
urls = ["https://github.com/google/benchmark/archive/bf585a2789e30585b4e3ce6baf11ef2750b54677.zip"], # 2020-11-26T11:14:03Z
strip_prefix = "benchmark-bf585a2789e30585b4e3ce6baf11ef2750b54677",
sha256 = "2a778d821997df7d8646c9c59b8edb9a573a6e04c534c01892a40aa524a7b68c",
)
http_archive(
name = "rules_cc",
sha256 = "9a446e9dd9c1bb180c86977a8dc1e9e659550ae732ae58bd2e8fd51e15b2c91d",
strip_prefix = "rules_cc-262ebec3c2296296526740db4aefce68c80de7fa",
urls = [
"https://github.com/bazelbuild/rules_cc/archive/262ebec3c2296296526740db4aefce68c80de7fa.zip",
],
)
http_archive(
name = "sfml",
urls = [

40
data/BUILD.bazel Normal file
View File

@ -0,0 +1,40 @@
filegroup(
name = "data",
srcs = glob([
"translations/*lst",
"textures/*lst",
"textures/*png",
"fonts/*lst",
"fonts/*ttf",
"music/*lst",
"music/*ogg",
"sounds/*lst",
"sounds/*wav",
"char/**/*lst",
"char/**/*png",
"objects/*lst",
"objects/*png",
"terrains/*lst",
"terrains/*png",
"env/**/*lst",
"env/**/*png",
"courses/**/*lst",
"courses/**/*png",
"courses/**/*dim",
"players/*lst",
"players/*png",
]),
visibility = [
"//visibility:public",
],
)

View File

@ -1,5 +1,5 @@
# list of fonts
*[name] normal [file] std.ttf
*[name] bold [file] stdbold.ttf
*[name] pc20 [file] pc_20.ttf
*[name] normal [file] //data/fonts/std.ttf
*[name] bold [file] //data/fonts/stdbold.ttf
*[name] pc20 [file] //data/fonts/pc_20.ttf

View File

@ -3,13 +3,13 @@
# Don't change the existing names, since
# other lists refer to this entries
*[name] credits_1 [file] credits1-cp.ogg
*[name] calmrace [file] calmrace-ks.ogg
*[name] freezingpoint [file] freezingpoint.ogg
*[name] lostrace_1 [file] lostrace-ks.ogg
*[name] options_1 [file] options1-jt.ogg
*[name] race_1 [file] race1-jt.ogg
*[name] raceintro [file] raceintro-ks.ogg
*[name] spunkyrace [file] spunkyrace-ks.ogg
*[name] start_1 [file] start1-jt.ogg
*[name] wonrace_1 [file] wonrace1-jt.ogg
*[name] credits_1 [file] //data/music/credits1-cp.ogg
*[name] calmrace [file] //data/music/calmrace-ks.ogg
*[name] freezingpoint [file] //data/music/freezingpoint.ogg
*[name] lostrace_1 [file] //data/music/lostrace-ks.ogg
*[name] options_1 [file] //data/music/options1-jt.ogg
*[name] race_1 [file] //data/music/race1-jt.ogg
*[name] raceintro [file] //data/music/raceintro-ks.ogg
*[name] spunkyrace [file] //data/music/spunkyrace-ks.ogg
*[name] start_1 [file] //data/music/start1-jt.ogg
*[name] wonrace_1 [file] //data/music/wonrace1-jt.ogg

View File

@ -1,17 +1,17 @@
*[file] avatar01.png
*[file] avatar02.png
*[file] avatar03.png
*[file] avatar04.png
*[file] avatar05.png
*[file] avatar06.png
*[file] avatar07.png
*[file] avatar08.png
*[file] avatar09.png
*[file] avatar10.png
*[file] avatar11.png
*[file] avatar12.png
*[file] avatar13.png
*[file] avatar14.png
*[file] avatar15.png
#*[file] avatar16.png
*[file] avatar17.png
*[file] //data/players/avatar01.png
*[file] //data/players/avatar02.png
*[file] //data/players/avatar03.png
*[file] //data/players/avatar04.png
*[file] //data/players/avatar05.png
*[file] //data/players/avatar06.png
*[file] //data/players/avatar07.png
*[file] //data/players/avatar08.png
*[file] //data/players/avatar09.png
*[file] //data/players/avatar10.png
*[file] //data/players/avatar11.png
*[file] //data/players/avatar12.png
*[file] //data/players/avatar13.png
*[file] //data/players/avatar14.png
*[file] //data/players/avatar15.png
#*[file] //data/players/avatar16.png
*[file] //data/players/avatar17.png

View File

@ -1,10 +1,10 @@
*[name] tree_hit [file] tree_hit.wav [vol] 1.0
*[name] snow_sound [file] snow_slide.wav [vol] 0.2
*[name] rock_sound [file] rock_slide.wav [vol] 1.0
*[name] ice_sound [file] ice_slide.wav [vol] 0.6
*[name] grass_sound [file] grass_slide.wav [vol] 0.6
*[name] mud_sound [file] mud_slide.wav [vol] 0.6
*[name] leaves_sound [file] leaves_slide.wav [vol] 0.6
*[name] pickup1 [file] pickup1.wav [vol] 1.0
*[name] pickup2 [file] pickup2.wav [vol] 1.0
*[name] pickup3 [file] pickup3.wav [vol] 1.0
*[name] tree_hit [file] //data/sounds/tree_hit.wav [vol] 1.0
*[name] snow_sound [file] //data/sounds/snow_slide.wav [vol] 0.2
*[name] rock_sound [file] //data/sounds/rock_slide.wav [vol] 1.0
*[name] ice_sound [file] //data/sounds/ice_slide.wav [vol] 0.6
*[name] grass_sound [file] //data/sounds/grass_slide.wav [vol] 0.6
*[name] mud_sound [file] //data/sounds/mud_slide.wav [vol] 0.6
*[name] leaves_sound [file] //data/sounds/leaves_slide.wav [vol] 0.6
*[name] pickup1 [file] //data/sounds/pickup1.wav [vol] 1.0
*[name] pickup2 [file] //data/sounds/pickup2.wav [vol] 1.0
*[name] pickup3 [file] //data/sounds/pickup3.wav [vol] 1.0

View File

@ -2,49 +2,49 @@
# Important: Do not change the IDs!
# -------------------------------------------------------------
* [id] 0 [name] logo [file] splash_1.png
* [id] 0 [name] logo [file] //data/textures/splash_1.png
* [id] 1 [name] snow_start [file] snowstart.png [repeat] 1
* [id] 2 [name] snow_track [file] snowtrack.png [repeat] 1
* [id] 3 [name] snow_stop [file] snowstop.png [repeat] 1
* [id] 4 [name] menu_title [file] menu_title.png [repeat] 0
* [id] 1 [name] snow_start [file] //data/textures/snowstart.png [repeat] 1
* [id] 2 [name] snow_track [file] //data/textures/snowtrack.png [repeat] 1
* [id] 3 [name] snow_stop [file] //data/textures/snowstop.png [repeat] 1
* [id] 4 [name] menu_title [file] //data/textures/menu_title.png [repeat] 0
* [id] 7 [name] herring_icon [file] herringicon.png [repeat] 0
* [id] 8 [name] gauge_outline [file] gaugeoutline.png [repeat] 0
* [id] 9 [name] gauge_energy_mask [file] gaugeenergymask.png [repeat] 0
* [id] 10 [name] gauge_speed_mask [file] gaugespeedmask.png [repeat] 0
* [id] 11 [name] listbox_arrows [file] listbox_arrows.png [repeat] 0
* [id] 12 [name] speedmeter [file] speedmeter.png [repeat] 0
* [id] 7 [name] herring_icon [file] //data/textures/herringicon.png [repeat] 0
* [id] 8 [name] gauge_outline [file] //data/textures/gaugeoutline.png [repeat] 0
* [id] 9 [name] gauge_energy_mask [file] //data/textures/gaugeenergymask.png [repeat] 0
* [id] 10 [name] gauge_speed_mask [file] //data/textures/gaugespeedmask.png [repeat] 0
* [id] 11 [name] listbox_arrows [file] //data/textures/listbox_arrows.png [repeat] 0
* [id] 12 [name] speedmeter [file] //data/textures/speedmeter.png [repeat] 0
* [id] 14 [name] light_butt [file] light_butt.png [repeat] 0
* [id] 15 [name] snow_butt [file] snow_butt.png [repeat] 0
* [id] 16 [name] wind_butt [file] wind_butt.png [repeat] 0
* [id] 17 [name] menu_bottom_left [file] menu_bottom_left.png [repeat] 0
* [id] 18 [name] menu_bottom_right [file] menu_bottom_right.png [repeat] 0
* [id] 19 [name] menu_top_left [file] menu_top_left.png [repeat] 0
* [id] 20 [name] menu_top_right [file] menu_top_right.png [repeat] 0
* [id] 21 [name] tuxbonus [file] tuxbonus.png [repeat] 0
* [id] 22 [name] mouse_cursor [file] mouse_cursor.png [repeat] 0
* [id] 23 [name] snow_particle [file] snowparticles.png [repeat] 0
* [id] 14 [name] light_butt [file] //data/textures/light_butt.png [repeat] 0
* [id] 15 [name] snow_butt [file] //data/textures/snow_butt.png [repeat] 0
* [id] 16 [name] wind_butt [file] //data/textures/wind_butt.png [repeat] 0
* [id] 17 [name] menu_bottom_left [file] //data/textures/menu_bottom_left.png [repeat] 0
* [id] 18 [name] menu_bottom_right [file] //data/textures/menu_bottom_right.png [repeat] 0
* [id] 19 [name] menu_top_left [file] //data/textures/menu_top_left.png [repeat] 0
* [id] 20 [name] menu_top_right [file] //data/textures/menu_top_right.png [repeat] 0
* [id] 21 [name] tuxbonus [file] //data/textures/tuxbonus.png [repeat] 0
* [id] 22 [name] mouse_cursor [file] //data/textures/mouse_cursor.png [repeat] 0
* [id] 23 [name] snow_particle [file] //data/textures/snowparticles.png [repeat] 0
* [id] 25 [name] energy_mask [file] energymask2.png [repeat] 0
* [id] 26 [name] mask_outline [file] mask_outline2.png [repeat] 0
* [id] 25 [name] energy_mask [file] //data/textures/energymask2.png [repeat] 0
* [id] 26 [name] mask_outline [file] //data/textures/mask_outline2.png [repeat] 0
* [id] 27 [name] ziff032 [file] ziff032.png [repeat] 0
* [id] 28 [name] mirror_butt [file] mirror_butt.png [repeat] 0
* [id] 30 [name] random_butt [file] random_butt.png [repeat] 0
* [id] 27 [name] ziff032 [file] //data/textures/ziff032.png [repeat] 0
* [id] 28 [name] mirror_butt [file] //data/textures/mirror_butt.png [repeat] 0
* [id] 30 [name] random_butt [file] //data/textures/random_butt.png [repeat] 0
* [id] 32 [name] time_icon [file] timeicon.png [repeat] 0
* [id] 32 [name] time_icon [file] //data/textures/timeicon.png [repeat] 0
* [id] 35 [name] speedknob [file] speedknob2.png
* [id] 35 [name] speedknob [file] //data/textures/speedknob2.png
* [id] 37 [name] checkbox [file] checkbox.png
* [id] 38 [name] checkmark_small [file] checkmark_small.png
* [id] 37 [name] checkbox [file] //data/textures/checkbox.png
* [id] 38 [name] checkmark_small [file] //data/textures/checkmark_small.png
* [id] 41 [name] snow1 [file] snow1.png [repeat] 0
* [id] 42 [name] snow2 [file] snow2.png [repeat] 0
* [id] 43 [name] snow3 [file] snow3.png [repeat] 0
* [id] 41 [name] snow1 [file] //data/textures/snow1.png [repeat] 0
* [id] 42 [name] snow2 [file] //data/textures/snow2.png [repeat] 0
* [id] 43 [name] snow3 [file] //data/textures/snow3.png [repeat] 0

View File

@ -21,6 +21,9 @@ cc_binary(
"credits.h",
"credits.cpp",
"depot.h",
"depot.cpp",
"env.h",
"env.cpp",
@ -156,5 +159,11 @@ cc_binary(
deps = [
"@sfml//:audio",
"@sfml//:graphics",
"@bazel_tools//tools/cpp/runfiles",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
],
data = [
"//data",
],
)

View File

@ -21,6 +21,7 @@ GNU General Public License for more details.
#include <SFML/Audio.hpp>
#include "audio.h"
#include "depot.h"
#include "spx.h"
// the global instances of the 2 audio classes
@ -62,17 +63,21 @@ bool CSound::LoadChunk(const std::string& name, const std::string& filename) {
return true;
}
bool CSound::LoadChunkDepot(const std::string &name, const std::string &depotpath) {
auto path = DepotMustResolveFile(depotpath);
return LoadChunk(name, path);
}
// Load all soundfiles listed in "/sounds/sounds.lst"
void CSound::LoadSoundList() {
CSPList list;
if (list.Load(param.sounds_dir, "sounds.lst")) {
if (list.LoadDepot("//data/sounds/sounds.lst")) {
sounds.reserve(list.size());
SoundIndex.reserve(list.size());
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
std::string name = SPStrN(*line, "name");
std::string soundfile = SPStrN(*line, "file");
std::string path = MakePathStr(param.sounds_dir, soundfile);
LoadChunk(name, path);
std::string depotpath = SPStrN(*line, "file");
LoadChunkDepot(name, depotpath);
}
}
}
@ -169,17 +174,21 @@ bool CMusic::LoadPiece(const std::string& name, const std::string& filename) {
return true;
}
bool CMusic::LoadPieceDepot(const std::string &name, const std::string &depotpath) {
auto path = DepotMustResolveFile(depotpath);
return LoadPiece(name, path);
}
void CMusic::LoadMusicList() {
// --- music ---
CSPList list;
if (list.Load(param.music_dir, "music.lst")) {
if (list.LoadDepot("//data/music/music.lst")) {
musics.reserve(list.size());
MusicIndex.reserve(list.size());
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
std::string name = SPStrN(*line, "name");
std::string musicfile = SPStrN(*line, "file");
std::string path = MakePathStr(param.music_dir, musicfile);
LoadPiece(name, path);
std::string depotpath = SPStrN(*line, "file");
LoadPieceDepot(name, depotpath);
}
} else {
Message("could not load music.lst");
@ -189,7 +198,7 @@ void CMusic::LoadMusicList() {
// --- racing themes ---
list.clear();
ThemesIndex.clear();
if (list.Load(param.music_dir, "racing_themes.lst")) {
if (list.LoadDepot("//data/music/racing_themes.lst")) {
themes.resize(list.size());
ThemesIndex.reserve(list.size());
std::size_t i = 0;

View File

@ -35,6 +35,7 @@ private:
public:
~CSound();
bool LoadChunk(const std::string& name, const std::string& filename);
bool LoadChunkDepot(const std::string& name, const std::string& depotpath);
void LoadSoundList();
std::size_t GetSoundIdx(const std::string& name) const;
@ -86,6 +87,7 @@ public:
~CMusic();
bool LoadPiece(const std::string& name, const std::string& filename);
bool LoadPieceDepot(const std::string& name, const std::string& depotpath);
void LoadMusicList();
std::size_t GetMusicIdx(const std::string& name) const;
std::size_t GetThemeIdx(const std::string& theme) const;

View File

@ -70,6 +70,13 @@ GNU General Public License for more details.
# include <sys/time.h>
# include <GL/glx.h>
# define SEP "/"
// System includes might include X11's Xlib, which might in turn `#define
// Status int`. This breaks abseil.
#if defined (Status)
#undef Status
#endif
#endif

View File

@ -20,6 +20,7 @@ GNU General Public License for more details.
#endif
#include "bh.h"
#include "depot.h"
#include "course.h"
#include "textures.h"
#include "ogl.h"
@ -318,7 +319,9 @@ void CCourse::FreeObjectTextures() {
bool CCourse::LoadElevMap() {
sf::Image img;
if (!img.loadFromFile(CourseDir + SEP "elev.png")) {
auto path = DepotMustResolveFile(CourseDir + "elev.png");
if (!img.loadFromFile(path)) {
Message("unable to open elev.png");
return false;
}
@ -357,7 +360,7 @@ void CCourse::LoadItemList() {
CSPList list;
if (!list.Load(CourseDir, "items.lst")) {
if (!list.LoadDepot(CourseDir + "items.lst")) {
Message("could not load items list");
return;
}
@ -376,7 +379,7 @@ void CCourse::LoadItemList() {
std::size_t type = ObjectIndex[name];
if (ObjTypes[type].texture == nullptr && ObjTypes[type].drawable) {
ObjTypes[type].texture = new TTexture();
ObjTypes[type].texture->Load(MakePathStr(param.obj_dir, ObjTypes[type].textureFile), false);
ObjTypes[type].texture->LoadDepot("//data/objects/" + ObjTypes[type].textureFile, false);
}
if (ObjTypes[type].collidable)
@ -427,81 +430,81 @@ static void CalcRandomTrees(double baseheight, double basediam, double &height,
diam = XRandom(height/diamfact, height);
}
bool CCourse::LoadAndConvertObjectMap() {
sf::Image treeImg;
if (!treeImg.loadFromFile(CourseDir + SEP "trees.png")) {
Message("unable to open trees.png");
return false;
}
treeImg.flipVertically();
int pad = 0;
int cnt = 0;
int depth = 4;
const unsigned char* data = (unsigned char*)treeImg.getPixelsPtr();
double height, diam;
CSPList savelist;
CollArr.clear();
NocollArr.clear();
for (unsigned int y = 0; y < ny; y++) {
for (unsigned int x = 0; x < nx; x++) {
int imgidx = (x + nx * y) * depth + pad;
int type = GetObject(&data[imgidx]);
if (type >= 0) {
cnt++;
double xx = (nx - x) / (double)((double)nx - 1.0) * curr_course->size.x;
double zz = -(int)(ny - y) / (double)((double)ny - 1.0) * curr_course->size.y;
if (ObjTypes[type].texture == nullptr && ObjTypes[type].drawable) {
ObjTypes[type].texture = new TTexture();
ObjTypes[type].texture->Load(MakePathStr(param.obj_dir, ObjTypes[type].textureFile), false);
}
// set random height and diam - see constants above
switch (type) {
case 5:
CalcRandomTrees(2.5, 2.5, height, diam);
break;
case 6:
CalcRandomTrees(3, 3, height, diam);
break;
case 7:
CalcRandomTrees(1.2, 1.2, height, diam);
break;
case 2:
case 3:
height = 6.0;
diam = 9.0;
break;
default:
height = 1;
diam = 1;
break;
}
if (ObjTypes[type].collidable)
CollArr.emplace_back(xx, FindYCoord(xx, zz), zz, height, diam, type);
else
NocollArr.emplace_back(xx, FindYCoord(xx, zz), zz, height, diam, ObjTypes[type]);
std::string line = "*[name]";
line += ObjTypes[type].name;
SPSetIntN(line, "x", x);
SPSetIntN(line, "z", y);
SPSetFloatN(line, "height", height, 1);
SPSetFloatN(line, "diam", diam, 1);
savelist.Add(line);
}
}
pad += (nx * depth) % 4;
}
std::string itemfile = CourseDir + SEP "items.lst";
savelist.Save(itemfile); // Convert trees.png to items.lst
return true;
}
//bool CCourse::LoadAndConvertObjectMap() {
// sf::Image treeImg;
//
// if (!treeImg.loadFromDepot(CourseDir + "trees.png")) {
// Message("unable to open trees.png");
// return false;
// }
// treeImg.flipVertically();
//
// int pad = 0;
// int cnt = 0;
// int depth = 4;
// const unsigned char* data = (unsigned char*)treeImg.getPixelsPtr();
// double height, diam;
// CSPList savelist;
//
// CollArr.clear();
// NocollArr.clear();
// for (unsigned int y = 0; y < ny; y++) {
// for (unsigned int x = 0; x < nx; x++) {
// int imgidx = (x + nx * y) * depth + pad;
// int type = GetObject(&data[imgidx]);
// if (type >= 0) {
// cnt++;
// double xx = (nx - x) / (double)((double)nx - 1.0) * curr_course->size.x;
// double zz = -(int)(ny - y) / (double)((double)ny - 1.0) * curr_course->size.y;
// if (ObjTypes[type].texture == nullptr && ObjTypes[type].drawable) {
// ObjTypes[type].texture = new TTexture();
// ObjTypes[type].texture->LoadDepot("//data/objects/" + ObjTypes[type].textureFile, false);
// }
//
// // set random height and diam - see constants above
// switch (type) {
// case 5:
// CalcRandomTrees(2.5, 2.5, height, diam);
// break;
// case 6:
// CalcRandomTrees(3, 3, height, diam);
// break;
// case 7:
// CalcRandomTrees(1.2, 1.2, height, diam);
// break;
//
// case 2:
// case 3:
// height = 6.0;
// diam = 9.0;
// break;
//
// default:
// height = 1;
// diam = 1;
// break;
// }
//
// if (ObjTypes[type].collidable)
// CollArr.emplace_back(xx, FindYCoord(xx, zz), zz, height, diam, type);
// else
// NocollArr.emplace_back(xx, FindYCoord(xx, zz), zz, height, diam, ObjTypes[type]);
//
// std::string line = "*[name]";
// line += ObjTypes[type].name;
// SPSetIntN(line, "x", x);
// SPSetIntN(line, "z", y);
// SPSetFloatN(line, "height", height, 1);
// SPSetFloatN(line, "diam", diam, 1);
// savelist.Add(line);
// }
// }
// pad += (nx * depth) % 4;
// }
// std::string itemfile = CourseDir + SEP "items.lst";
// savelist.Save(itemfile); // Convert trees.png to items.lst
// return true;
//}
// --------------------------------------------------------------------
// LoadObjectTypes
@ -510,7 +513,7 @@ bool CCourse::LoadAndConvertObjectMap() {
bool CCourse::LoadObjectTypes() {
CSPList list;
if (!list.Load(param.obj_dir, "object_types.lst")) {
if (!list.LoadDepot("//data/objects/object_types.lst")) {
Message("could not load object types");
return false;
}
@ -567,7 +570,7 @@ int CCourse::GetTerrain(const unsigned char* pixel) const {
bool CCourse::LoadTerrainTypes() {
CSPList list;
if (!list.Load(param.terr_dir, "terrains.lst")) {
if (!list.LoadDepot("//data/terrains/terrains.lst")) {
Message("could not load terrain types");
return false;
}
@ -599,7 +602,8 @@ bool CCourse::LoadTerrainTypes() {
bool CCourse::LoadTerrainMap() {
sf::Image terrImage;
if (!terrImage.loadFromFile(CourseDir + SEP "terrain.png")) {
auto path = DepotMustResolveFile(CourseDir + "terrain.png");
if (!terrImage.loadFromFile(path)) {
Message("unable to open terrain.png");
return false;
}
@ -619,7 +623,7 @@ bool CCourse::LoadTerrainMap() {
Fields[arridx].terrain = terr;
if (TerrList[terr].texture == nullptr) {
TerrList[terr].texture = new TTexture();
TerrList[terr].texture->Load(param.terr_dir, TerrList[terr].textureFile, true);
TerrList[terr].texture->LoadDepot("//data/terrains/" + TerrList[terr].textureFile, true);
}
}
pad += (nx * depth) % 4;
@ -634,7 +638,7 @@ bool CCourse::LoadTerrainMap() {
bool CCourseList::Load(const std::string& dir) {
CSPList list;
if (!list.Load(dir, "courses.lst")) {
if (!list.LoadDepot(dir + "courses.lst")) {
Message("could not load courses.lst");
return false;
}
@ -647,39 +651,37 @@ bool CCourseList::Load(const std::string& dir) {
courses[i].name = SPStrN(*line1, "name");
courses[i].dir = SPStrN(*line1, "dir", "nodir");
std::string coursepath = MakePathStr(dir, courses[i].dir);
if (DirExists(coursepath.c_str())) {
// preview
std::string previewfile = coursepath + SEP "preview.png";
courses[i].preview = new TTexture();
if (!courses[i].preview->Load(previewfile, false)) {
Message("couldn't load previewfile");
}
std::string coursepath = dir + courses[i].dir + "/";
// params
std::string paramfile = coursepath + SEP "course.dim";
if (!paramlist.Load(paramfile)) {
Message("could not load course.dim");
}
const std::string& line2 = paramlist.front();
courses[i].author = SPStrN(line2, "author", Trans.Text(109));
courses[i].size.x = SPFloatN(line2, "width", 100);
courses[i].size.y = SPFloatN(line2, "length", 1000);
courses[i].play_size.x = SPFloatN(line2, "play_width", 90);
courses[i].play_size.y = SPFloatN(line2, "play_length", 900);
courses[i].angle = SPFloatN(line2, "angle", 10);
courses[i].scale = SPFloatN(line2, "scale", 10);
courses[i].start.x = SPFloatN(line2, "startx", 50);
courses[i].start.y = SPFloatN(line2, "starty", 5);
courses[i].env = Env.GetEnvIdx(SPStrN(line2, "env", "etr"));
courses[i].music_theme = Music.GetThemeIdx(SPStrN(line2, "theme", "normal"));
courses[i].use_keyframe = SPBoolN(line2, "use_keyframe", false);
courses[i].finish_brake = SPFloatN(line2, "finish_brake", 20);
if (paramlist.size() >= 2)
courses[i].SetTranslatedData(paramlist.back());
paramlist.clear(); // the list is used several times
std::string previewfile = coursepath + "preview.png";
courses[i].preview = new TTexture();
if (!courses[i].preview->LoadDepot(previewfile, false)) {
Message("couldn't load previewfile");
}
// params
std::string paramfile = coursepath + "course.dim";
if (!paramlist.LoadDepot(paramfile)) {
Message("could not load course.dim");
}
const std::string& line2 = paramlist.front();
courses[i].author = SPStrN(line2, "author", Trans.Text(109));
courses[i].size.x = SPFloatN(line2, "width", 100);
courses[i].size.y = SPFloatN(line2, "length", 1000);
courses[i].play_size.x = SPFloatN(line2, "play_width", 90);
courses[i].play_size.y = SPFloatN(line2, "play_length", 900);
courses[i].angle = SPFloatN(line2, "angle", 10);
courses[i].scale = SPFloatN(line2, "scale", 10);
courses[i].start.x = SPFloatN(line2, "startx", 50);
courses[i].start.y = SPFloatN(line2, "starty", 5);
courses[i].env = Env.GetEnvIdx(SPStrN(line2, "env", "etr"));
courses[i].music_theme = Music.GetThemeIdx(SPStrN(line2, "theme", "normal"));
courses[i].use_keyframe = SPBoolN(line2, "use_keyframe", false);
courses[i].finish_brake = SPFloatN(line2, "finish_brake", 20);
if (paramlist.size() >= 2)
courses[i].SetTranslatedData(paramlist.back());
paramlist.clear(); // the list is used several times
}
list.MakeIndex(index, "dir");
return true;
@ -700,14 +702,14 @@ void CCourse::FreeCourseList() {
bool CCourse::LoadCourseList() {
CSPList list;
if (!list.Load(param.common_course_dir, "groups.lst")) {
if (!list.LoadDepot("//data/courses/groups.lst")) {
Message("could not load groups.lst");
return false;
}
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
std::string dir = SPStrN(*line, "dir", "nodir");
CourseLists[dir].Load(MakePathStr(param.common_course_dir, dir));
CourseLists[dir].Load("//data/courses/" + dir + "/");
CourseLists[dir].name = dir;
}
currentCourseList = &CourseLists["default"];
@ -740,7 +742,7 @@ bool CCourse::LoadCourse(TCourse* course) {
if (course != curr_course || g_game.force_treemap) {
ResetCourse();
curr_course = course;
CourseDir = param.common_course_dir + SEP + currentCourseList->name + SEP + curr_course->dir;
CourseDir = "//data/courses/" + currentCourseList->name + "/" + curr_course->dir + "/";
start_pt.x = course->start.x;
start_pt.y = -course->start.y;
@ -763,14 +765,16 @@ bool CCourse::LoadCourse(TCourse* course) {
}
// ................................................................
std::string itemfile = CourseDir + SEP "items.lst";
std::string itemfile = DepotMustResolveFile(CourseDir + "items.lst");
bool itemsexists = FileExists(itemfile);
const CControl *ctrl = g_game.player->ctrl;
if (itemsexists && !g_game.force_treemap)
LoadItemList();
else
LoadAndConvertObjectMap();
else {
Message("Cannot convert");
exit(1);
}
g_game.force_treemap = false;
// ................................................................

View File

@ -126,6 +126,7 @@ public:
std::string name;
bool Load(const std::string& dir);
bool LoadDepot(const std::string& dir);
void Free();
TCourse& operator[](std::size_t idx) { return courses[idx]; }
const TCourse& operator[](std::size_t idx) const { return courses[idx]; }

View File

@ -45,7 +45,7 @@ sf::RenderStates states(sf::BlendAlpha);
void CCredits::LoadCreditList() {
CSPList list;
if (!list.Load(param.data_dir, "credits.lst")) {
if (!list.LoadDepot("//data/credits.lst")) {
Message("could not load credits list");
return;
}

55
src/depot.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "depot.h"
#include "common.h"
#include "absl/strings/strip.h"
#include "absl/strings/str_format.h"
#include "tools/cpp/runfiles/runfiles.h"
using bazel::tools::cpp::runfiles::Runfiles;
static std::unique_ptr<Runfiles> runfiles = nullptr;
void DepotInit(const std::string &argv0) {
if (runfiles != nullptr) {
Message("DepotInit cannot be called twice");
exit(1);
}
std::string err;
auto rf = Runfiles::Create(argv0, &err);
if (rf == nullptr) {
Message("Runfiles::Create", err);
exit(1);
}
runfiles = std::unique_ptr<Runfiles>(rf);
}
absl::StatusOr<std::string> DepotResolveFile(const std::string &depotpath) {
if (runfiles == nullptr) {
return absl::FailedPreconditionError("depot not initialized");
}
absl::string_view sv(depotpath);
if (!absl::ConsumePrefix(&sv, "//")) {
return absl::InvalidArgumentError("path does not start with //");
}
auto loc = runfiles->Rlocation("extremetuxracer/" + std::string(sv));
if (loc.empty()) {
return absl::NotFoundError("depot path not found in runfiles");
}
if (access(loc.c_str(), F_OK) != 0) {
return absl::NotFoundError("depot path does not exit");
}
return loc;
}
std::string DepotMustResolveFile(const std::string &depotpath) {
auto r = DepotResolveFile(depotpath);
if (!r.ok()) {
auto msg = absl::StrFormat("Could not resolve depot path %s: %s", depotpath, r.status().ToString());
Message(msg);
exit(1);
}
return r.value();
}

13
src/depot.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef DEPOT_H
#define DEPOT_H
#include "absl/status/statusor.h"
#include <optional>
#include <string>
void DepotInit(const std::string &argv0);
absl::StatusOr<std::string> DepotResolveFile(const std::string &depotpath);
std::string DepotMustResolveFile(const std::string &depotpath);
#endif

View File

@ -122,7 +122,7 @@ void CEnvironment::Reset() {
bool CEnvironment::LoadEnvironmentList() {
CSPList list(true);
if (!list.Load(param.env_dir2, "environment.lst")) {
if (!list.LoadDepot("//data/env/environment.lst")) {
Message("could not load environment.lst");
return false;
}
@ -140,19 +140,17 @@ bool CEnvironment::LoadEnvironmentList() {
std::string CEnvironment::GetDir(std::size_t location, std::size_t light) const {
if (location >= locs.size()) return "";
if (light >= 4) return "";
std::string res =
param.env_dir2 + SEP +
locs[location].name + SEP + lightcond[light];
std::string res = "//data/env/" + locs[location].name + "/" + lightcond[light] + "/";
return res;
}
void CEnvironment::LoadSkyboxSide(std::size_t index, const std::string& EnvDir, const std::string& name, bool high_res) {
bool loaded = false;
if (param.perf_level > 3 && high_res)
loaded = Skybox[index].Load(EnvDir, name + "H.png");
loaded = Skybox[index].LoadDepot(EnvDir + name + "H.png");
if (!loaded)
Skybox[index].Load(EnvDir, name + ".png");
Skybox[index].LoadDepot(EnvDir + name + ".png");
}
void CEnvironment::LoadSkybox(const std::string& EnvDir, bool high_res) {
@ -171,7 +169,7 @@ void CEnvironment::LoadLight(const std::string& EnvDir) {
static const std::string idxstr = "[fog]-1[0]0[1]1[2]2[3]3[4]4[5]5[6]6";
CSPList list;
if (!list.Load(EnvDir, "light.lst")) {
if (!list.LoadDepot(EnvDir + "light.lst")) {
Message("could not load light file");
return;
}

View File

@ -20,6 +20,7 @@ GNU General Public License for more details.
#include <etr_config.h>
#endif
#include "depot.h"
#include "font.h"
#include "spx.h"
#include "ogl.h"
@ -123,9 +124,15 @@ int CFont::LoadFont(const std::string& name, const std::string& dir, const std::
return LoadFont(name, MakePathStr(dir, filename));
}
int CFont::LoadFontDepot(const std::string& name, const std::string &depotpath) {
auto path = DepotMustResolveFile(depotpath);
return LoadFont(name, path);
}
bool CFont::LoadFontlist() {
CSPList list;
if (!list.Load(param.font_dir, "fonts.lst")) {
if (!list.LoadDepot("//data/fonts/fonts.lst")) {
fonts.push_back(new sf::Font()); // Insert an empty font, otherwise ETR will crash
return false;
}
@ -133,10 +140,10 @@ bool CFont::LoadFontlist() {
fonts.reserve(list.size());
fontindex.reserve(list.size());
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
std::string fontfile = SPStrN(*line, "file");
std::string depotpath = SPStrN(*line, "file");
std::string name = SPStrN(*line, "name");
int ftidx = LoadFont(name, param.font_dir, fontfile);
int ftidx = LoadFontDepot(name, depotpath);
if (ftidx < 0) {
Message("couldn't load font", name);
}

View File

@ -47,6 +47,7 @@ public:
void Clear();
int LoadFont(const std::string& name, const std::string& dir, const std::string& filename);
int LoadFont(const std::string& name, const std::string& path);
int LoadFontDepot(const std::string& name, const std::string& depotpath);
bool LoadFontlist();
std::size_t GetFontIdx(const std::string &name) const;
const sf::Font& getCurrentFont() const { return *fonts[curr_font]; }

View File

@ -302,9 +302,6 @@ void InitConfig() {
if (!DirExists(param.config_dir.c_str())) {
mkdir(param.config_dir.c_str(), 0775);
}
param.data_dir = ETR_DATA_DIR;
param.data_dir += SEP;
param.data_dir += "etr";
param.save_dir = param.config_dir;
param.configfile = param.config_dir + SEP "options.txt";
if (FileExists(param.configfile)) {
@ -319,17 +316,17 @@ void InitConfig() {
#endif /* WIN32 */
param.screenshot_dir = param.save_dir + SEP "screenshots";
param.obj_dir = param.data_dir + SEP "objects";
param.env_dir2 = param.data_dir + SEP "env";
param.char_dir = param.data_dir + SEP "char";
param.terr_dir = param.data_dir + SEP "terrains";
param.tex_dir = param.data_dir + SEP "textures";
param.common_course_dir = param.data_dir + SEP "courses";
param.sounds_dir = param.data_dir + SEP "sounds";
param.music_dir = param.data_dir + SEP "music";
param.font_dir = param.data_dir + SEP "fonts";
param.trans_dir = param.data_dir + SEP "translations";
param.player_dir = param.data_dir + SEP "players";
//param.obj_dir = param.data_dir + SEP "objects";
//param.env_dir2 = param.data_dir + SEP "env";
//param.char_dir = param.data_dir + SEP "char";
//param.terr_dir = param.data_dir + SEP "terrains";
//param.tex_dir = param.data_dir + SEP "textures";
//param.common_course_dir = param.data_dir + SEP "courses";
//param.sounds_dir = param.data_dir + SEP "sounds";
//param.music_dir = param.data_dir + SEP "music";
//param.font_dir = param.data_dir + SEP "fonts";
//param.trans_dir = param.data_dir + SEP "translations";
//param.player_dir = param.data_dir + SEP "players";
param.ui_snow = true;
param.view_mode = FOLLOW;

View File

@ -22,20 +22,8 @@ GNU General Public License for more details.
struct TParam {
// defined at runtime:
std::string config_dir;
std::string data_dir;
std::string save_dir;
std::string common_course_dir;
std::string obj_dir;
std::string terr_dir;
std::string char_dir;
std::string env_dir2;
std::string tex_dir;
std::string sounds_dir;
std::string music_dir;
std::string screenshot_dir;
std::string font_dir;
std::string trans_dir;
std::string player_dir;
std::string configfile;
// ------------------------------------

View File

@ -36,7 +36,7 @@ CEvents Events;
bool CEvents::LoadEventList() {
CSPList list;
if (!list.Load(param.common_course_dir, "events.lst")) {
if (!list.LoadDepot("//data/courses/events.lst")) {
Message("could not load events.lst");
return false;
}
@ -158,8 +158,8 @@ void CPlayers::AddPlayer(const std::string& name, const std::string& avatar) {
}
void CPlayers::SetDefaultPlayers() {
plyr.emplace_back("Racer", FindAvatar("avatar01.png"));
plyr.emplace_back("Bunny", FindAvatar("avatar02.png"));
plyr.emplace_back("Racer", FindAvatar("//data/players/avatar01.png"));
plyr.emplace_back("Bunny", FindAvatar("//data/players/avatar02.png"));
}
bool CPlayers::LoadPlayers() {
@ -241,17 +241,17 @@ void CPlayers::AllocControl(std::size_t player) {
bool CPlayers::LoadAvatars() {
CSPList list;
if (!list.Load(param.player_dir, "avatars.lst")) {
if (!list.LoadDepot("//data/players/avatars.lst")) {
Message("could not load avators.lst");
return false;
}
avatars.reserve(list.size());
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
std::string filename = SPStrN(*line, "file", "unknown");
std::string depotpath = SPStrN(*line, "file", "unknown");
TTexture* texture = new TTexture();
if (texture && texture->Load(param.player_dir, filename)) {
avatars.emplace_back(filename, texture);
if (texture && texture->LoadDepot(depotpath)) {
avatars.emplace_back(depotpath, texture);
} else
delete texture;
}
@ -292,7 +292,7 @@ CCharacter::~CCharacter() {
bool CCharacter::LoadCharacterList() {
CSPList list;
if (!list.Load(param.char_dir, "characters.lst")) {
if (!list.LoadDepot("//data/char/characters.lst")) {
Message("could not load characters.lst");
return false;
}
@ -305,33 +305,30 @@ bool CCharacter::LoadCharacterList() {
std::string typestr = SPStrN(*line, "type", "unknown");
CharList[i].type = SPIntN(char_type_index, typestr, -1);
std::string charpath = MakePathStr(param.char_dir, CharList[i].dir);
if (DirExists(charpath.c_str())) {
std::string previewfile = charpath + SEP "preview.png";
std::string charpath = "//data/char/" + CharList[i].dir + "/";
TCharacter* ch = &CharList[i];
ch->preview = new TTexture();
if (!ch->preview->Load(previewfile, false)) {
Message("could not load previewfile of character");
// texid = Tex.TexID (NO_PREVIEW);
}
ch->shape = new CCharShape;
if (ch->shape->Load(charpath, "shape.lst", false) == false) {
delete ch->shape;
ch->shape = nullptr;
Message("could not load character shape");
}
ch->frames[0].Load(charpath, "start.lst");
ch->finishframesok = true;
ch->frames[1].Load(charpath, "finish.lst");
if (ch->frames[1].loaded == false) ch->finishframesok = false;
ch->frames[2].Load(charpath, "wonrace.lst");
if (ch->frames[2].loaded == false) ch->finishframesok = false;
ch->frames[3].Load(charpath, "lostrace.lst");
if (ch->frames[3].loaded == false) ch->finishframesok = false;
TCharacter* ch = &CharList[i];
ch->preview = new TTexture();
if (!ch->preview->LoadDepot(charpath + "preview.png", false)) {
Message("could not load previewfile of character");
// texid = Tex.TexID (NO_PREVIEW);
}
ch->shape = new CCharShape;
if (ch->shape->LoadDepot(charpath + "shape.lst", false) == false) {
delete ch->shape;
ch->shape = nullptr;
Message("could not load character shape");
}
ch->frames[0].LoadDepot(charpath + "start.lst");
ch->finishframesok = true;
ch->frames[1].LoadDepot(charpath + "finish.lst");
if (ch->frames[1].loaded == false) ch->finishframesok = false;
ch->frames[2].LoadDepot(charpath + "wonrace.lst");
if (ch->frames[2].loaded == false) ch->finishframesok = false;
ch->frames[3].LoadDepot(charpath + "lostrace.lst");
if (ch->frames[3].loaded == false) ch->finishframesok = false;
}
return !CharList.empty();
}

View File

@ -104,11 +104,11 @@ void CKeyframe::Reset() {
frames.clear();
}
bool CKeyframe::Load(const std::string& dir, const std::string& filename) {
if (loaded && loadedfile == filename) return true;
bool CKeyframe::LoadDepot(const std::string &depotpath) {
if (loaded && loadedfile == depotpath) return true;
CSPList list;
if (list.Load(dir, filename)) {
if (list.LoadDepot(depotpath)) {
frames.resize(list.size());
std::size_t i = 0;
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) {
@ -139,10 +139,10 @@ bool CKeyframe::Load(const std::string& dir, const std::string& filename) {
frames[i].val[18] = pp.y;
}
loaded = true;
loadedfile = filename;
loadedfile = depotpath;
return true;
} else {
Message("keyframe not found:", filename);
Message("keyframe not found:", depotpath);
loaded = false;
return false;
}

View File

@ -59,7 +59,7 @@ public:
void Reset();
void Update(float timestep);
void UpdateTest(float timestep, CCharShape *shape);
bool Load(const std::string& dir, const std::string& filename);
bool LoadDepot(const std::string& depotpath);
void CalcKeyframe(std::size_t idx, CCharShape *shape, const TVector3d& refpos_) const;
// test and editing

View File

@ -20,6 +20,7 @@ GNU General Public License for more details.
#endif
#include "bh.h"
#include "depot.h"
#include "textures.h"
#include "ogl.h"
#include "splash_screen.h"
@ -65,6 +66,8 @@ int main(int argc, char **argv) {
std::cout << "\n----------- Extreme Tux Racer " ETR_VERSION_STRING " ----------------";
std::cout << "\n----------- (C) 2010-2020 Extreme Tuxracer Team --------\n\n";
DepotInit(argv[0]);
std::srand(std::time(nullptr));
InitConfig();
InitGame(argc, argv);

View File

@ -18,6 +18,7 @@ GNU General Public License for more details.
#include <etr_config.h>
#endif
#include "depot.h"
#include "spx.h"
#include <sstream>
@ -425,6 +426,11 @@ bool CSPList::Load(const std::string& dir, const std::string& filename) {
return Load(MakePathStr(dir, filename));
}
bool CSPList::LoadDepot(const std::string &depotpath) {
auto path = DepotMustResolveFile(depotpath);
return Load(path);
}
bool CSPList::Save(const std::string &filepath) const {
std::ofstream tempfile(filepath);
if (!tempfile) {

View File

@ -103,6 +103,7 @@ public:
void Add(const std::string& line = emptyString);
void Add(std::string&& line);
void Print() const;
bool LoadDepot(const std::string &depotpath);
bool Load(const std::string &filepath);
bool Load(const std::string& dir, const std::string& filename);
bool Save(const std::string &filepath) const;

View File

@ -19,6 +19,7 @@ GNU General Public License for more details.
#include <etr_config.h>
#endif
#include "depot.h"
#include "textures.h"
#include "spx.h"
#include "winsys.h"
@ -45,6 +46,11 @@ bool TTexture::Load(const std::string& filename, bool repeatable) {
return texture.loadFromFile(filename);
}
bool TTexture::LoadDepot(const std::string &depotpath, bool repeatable) {
auto path = DepotMustResolveFile(depotpath);
return Load(path, repeatable);
}
bool TTexture::Load(const std::string& dir, const std::string& filename, bool repeatable) {
return Load(MakePathStr(dir, filename), repeatable);
}
@ -179,7 +185,7 @@ CTexture::~CTexture() {
bool CTexture::LoadTextureList() {
FreeTextureList();
CSPList list;
if (list.Load(param.tex_dir, "textures.lst")) {
if (list.LoadDepot("//data/textures/textures.lst")) {
for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
int id = SPIntN(*line, "id", -1);
CommonTex.resize(std::max(CommonTex.size(), (std::size_t)id+1));
@ -187,7 +193,7 @@ bool CTexture::LoadTextureList() {
bool rep = SPBoolN(*line, "repeat", false);
if (id >= 0) {
CommonTex[id] = new TTexture();
CommonTex[id]->Load(param.tex_dir, texfile, rep);
CommonTex[id]->LoadDepot(texfile, rep);
} else Message("wrong texture id in textures.lst");
}
} else {

View File

@ -65,6 +65,7 @@ class TTexture {
sf::Texture texture;
friend class CTexture;
public:
bool LoadDepot(const std::string& depotpath, bool repeatable = false);
bool Load(const std::string& filename, bool repeatable = false);
bool Load(const std::string& dir, const std::string& filename, bool repeatable = false);
bool Load(const std::string& dir, const char* filename, bool repeatable = false) { return Load(dir, std::string(filename), repeatable); }

View File

@ -205,8 +205,10 @@ void SaveToolCharacter() {
}
void ReloadToolCharacter() {
TestChar.Load(char_dir, char_file, true);
charchanged = false;
Message("ReloadToolCharacter unimplemented");
exit(1);
//TestChar.Load(char_dir, char_file, true);
//charchanged = false;
}
void SaveToolFrame() {
@ -216,25 +218,29 @@ void SaveToolFrame() {
}
void CTools::SetParameter(const std::string& dir, const std::string& file) {
char_dir = param.char_dir + SEP + dir;
char_file = "shape.lst";
frame_file = file;
Message("SetParameter unimplemented");
exit(1);
//char_dir = param.char_dir + SEP + dir;
//char_file = "shape.lst";
//frame_file = file;
}
void CTools::Enter() {
if (TestChar.Load(char_dir, char_file, true) == false) {
Message("could not load 'shape.lst'");
Winsys.Terminate();
}
if (TestFrame.Load(char_dir, frame_file) == false) {
Message("could not load 'frame.lst'");
Winsys.Terminate();
}
charchanged = false;
framechanged = false;
Message("Enter unimplemented");
exit(1);
//if (TestChar.Load(char_dir, char_file, true) == false) {
// Message("could not load 'shape.lst'");
// Winsys.Terminate();
//}
//if (TestFrame.Load(char_dir, frame_file) == false) {
// Message("could not load 'frame.lst'");
// Winsys.Terminate();
//}
//charchanged = false;
//framechanged = false;
InitCharTools();
InitFrameTools();
//InitCharTools();
//InitFrameTools();
}
void CTools::Keyb(sf::Keyboard::Key key, bool release, int x, int y) {

View File

@ -194,7 +194,7 @@ static std::wstring UnicodeStr(const std::string& s) {
void CTranslation::LoadLanguages() {
CSPList list;
if (!list.Load(param.trans_dir, "languages.lst")) {
if (!list.LoadDepot("//data/translations/languages.lst")) {
Message("could not load language list");
return;
}
@ -223,9 +223,9 @@ void CTranslation::LoadTranslations(std::size_t langidx) {
if (langidx == 0 || langidx >= languages.size()) return;
CSPList list;
std::string filename = languages[langidx].lang + ".lst";
if (!list.Load(param.trans_dir, filename)) {
Message("could not load translations list:", filename);
std::string depotpath = "//translations/" + languages[langidx].lang + ".lst";
if (!list.LoadDepot(depotpath)) {
Message("could not load translations list:", depotpath);
return;
}

View File

@ -419,15 +419,15 @@ void CCharShape::Draw() {
// --------------------------------------------------------------------
bool CCharShape::Load(const std::string& dir, const std::string& filename, bool with_actions) {
bool CCharShape::LoadDepot(const std::string &depotpath, bool with_actions) {
CSPList list;
useActions = with_actions;
CreateRootNode();
newActions = true;
if (!list.Load(dir, filename)) {
Message("could not load character", filename);
if (!list.LoadDepot(depotpath)) {
Message("could not load character", depotpath);
return false;
}

View File

@ -133,7 +133,7 @@ public:
void Reset();
void Draw();
void DrawShadow() const;
bool Load(const std::string& dir, const std::string& filename, bool with_actions);
bool LoadDepot(const std::string& depotpath, bool with_actions);
void AdjustOrientation(CControl *ctrl, double dtime,
double dist_from_surface, const TVector3d& surf_nml);