Skip to content

Commit 34467bb

Browse files
authored
Merge pull request #7 from OpenDriver2/nstd-conversion
Viewer and exporter update
2 parents 3b89a88 + 300e90b commit 34467bb

75 files changed

Lines changed: 4564 additions & 2575 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor/Build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -ex
33

44
cd "$APPVEYOR_BUILD_FOLDER"
55

6-
./premake5 gmake2
6+
./premake5 gmake2 verbose
77

88
for config in debug release
99
do

.appveyor/Install.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@echo off
22

3+
cd %APPVEYOR_BUILD_FOLDER%
4+
git submodule update --init --recursive
5+
36
appveyor DownloadFile %windows_premake_url% -FileName premake5.zip
47
7z x premake5.zip -o%project_folder% -aoa
58

.appveyor/Install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -ex
33

44
cd "$APPVEYOR_BUILD_FOLDER"
5+
git submodule update --init --recursive
56

67
# Download premake5
78
# because it isn't in the repos (yet?)

.gitignore

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,18 @@ Icon
4848
*.vcxproj.filters
4949
*.sln
5050
*.exe
51+
*.ilk
52+
*.recipe
53+
*.idb
54+
55+
bin/*
56+
dependencies/SDL2
5157
DriverLevelTool/bin/*
5258
DriverLevelTool/obj/*
5359
DriverSoundTool/bin/*
5460
DriverSoundTool/obj/*
55-
ImageUnpackTool/bin/*
56-
ImageUnpackTool/obj/*
61+
Driver2CutsceneTool/bin/*
62+
Driver2CutsceneTool/obj/*
63+
Driver2MissionTool/bin/*
64+
Driver2MissionTool/obj/*
5765
LEVELS/*

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "dependencies/libnstd"]
2+
path = dependencies/libnstd
3+
url = https://github.com/craflin/libnstd.git
4+
[submodule "dependencies/imgui"]
5+
path = dependencies/imgui
6+
url = https://github.com/ocornut/imgui.git

Driver2CutsceneTool/cutscene_tool.cpp

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
#include <math.h>
2-
1+
#include <stdlib.h>
2+
#include <stdio.h>
33
#include <malloc.h>
4-
#include "core/VirtualStream.h"
54
#include "core/cmdlib.h"
6-
#include "math/dktypes.h"
7-
#include "util/image.h"
8-
#include "util/util.h"
9-
#include <string>
10-
#include <DriverLevelTool/driver_routines/d2_types.h>
5+
#include "core/dktypes.h"
6+
#include <string.h>
7+
#include <nstd/Directory.hpp>
8+
#include <nstd/File.hpp>
9+
#include <nstd/String.hpp>
10+
11+
#include "math/psx_math_types.h"
1112

1213
#define MAX_FILE_CUTSCENES 15
1314
#define REPLAY_BUFFER_MINSIZE 2280
@@ -165,13 +166,10 @@ struct REPLAY_STREAM_HEADER
165166
void UnpackCutsceneFile(const char* filename)
166167
{
167168
// replace extension with .den
168-
std::string cut_name = filename;
169-
170-
size_t str_idx = cut_name.find_last_of(".");
171-
cut_name = cut_name.substr(0, str_idx);
169+
String cut_name = String::fromCString(filename);
170+
cut_name = File::basename(cut_name, File::extension(cut_name));
172171

173172
char* buffer;
174-
char folderPath[512];
175173

176174
CUTSCENE_HEADER header;
177175
FILE* fp = fopen(filename, "rb");
@@ -188,8 +186,8 @@ void UnpackCutsceneFile(const char* filename)
188186
Msg("Max replay buffer size: %d\n", header.maxsize);
189187

190188
// make the folder
191-
sprintf(folderPath, "%s", cut_name.c_str());
192-
mkdirRecursive(folderPath, true);
189+
String folderPath = cut_name;
190+
Directory::create(folderPath);
193191

194192
buffer = (char*)malloc(0x200000);
195193

@@ -235,9 +233,7 @@ void UnpackCutsceneFile(const char* filename)
235233
}
236234

237235
// save separate file
238-
sprintf(folderPath, "%s/%s_%d.D2RP", cut_name.c_str(), cut_name.c_str(), i);
239-
240-
FILE* wp = fopen(folderPath, "wb");
236+
FILE* wp = fopen(String::fromPrintf("%s/%s_%d.D2RP", (char*)cut_name, (char*)cut_name, i), "wb");
241237
if (wp)
242238
{
243239
MsgWarning("\tSaving '%s', at %d, %d bytes\n", folderPath, header.data[i].offset, header.data[i].size);
@@ -255,7 +251,6 @@ void PackCutsceneFile(const char* foldername)
255251
{
256252
int offset;
257253
char* buffer;
258-
char folderPath[512];
259254
CUTSCENE_HEADER header;
260255
header.maxsize = REPLAY_BUFFER_MINSIZE;
261256

@@ -268,8 +263,8 @@ void PackCutsceneFile(const char* foldername)
268263

269264
for (int i = 0; i < MAX_FILE_CUTSCENES; i++)
270265
{
271-
sprintf(folderPath, "%s/%s_%d.D2RP", foldername, foldername, i);
272-
FILE* fp = fopen(folderPath, "rb");
266+
String folderPath = String::fromPrintf("%s/%s_%d.D2RP", foldername, foldername, i);
267+
FILE* fp = fopen(String::fromPrintf("%s/%s_%d.D2RP", foldername, foldername, i), "rb");
273268
if (fp)
274269
{
275270
if (i == 0)
@@ -293,7 +288,7 @@ void PackCutsceneFile(const char* foldername)
293288
replays[i] = (char*)malloc(size);
294289
repsizes[i] = size;
295290

296-
MsgWarning("\tLoaded '%s', %d bytes\n", folderPath, size);
291+
MsgWarning("\tLoaded '%s', %d bytes\n", (char*)folderPath, size);
297292
fread(replays[i], 1, size, fp);
298293
fclose(fp);
299294

@@ -322,11 +317,25 @@ void PackCutsceneFile(const char* foldername)
322317
char* bufptr = (char*)sheader;
323318
char* pingBufferPtr = bufptr + sizeof(PLAYBACKCAMERA) * MAX_REPLAY_CAMERAS;
324319

320+
// copy all pings to new position and remove deleted car pings too
321+
/*for (int j = 0; j < MAX_REPLAY_PINGS; j++)
322+
{
323+
PING_PACKET packet = *(PING_PACKET*)pingBufferPtr;
324+
325+
if(packet.carId != -1 && packet.frame != 0xffff)
326+
{
327+
*(PING_PACKET*)bufptr = packet;
328+
bufptr += sizeof(PING_PACKET);
329+
}
330+
331+
pingBufferPtr += sizeof(PING_PACKET);
332+
}*/
333+
325334
memmove(bufptr, pingBufferPtr, sizeof(PING_PACKET) * MAX_REPLAY_PINGS);
326335

327336
// shrink size
328337
repsizes[i] -= sizeof(PLAYBACKCAMERA) * MAX_REPLAY_CAMERAS;
329-
MsgAccept("\tShrinking '%s', now %d bytes\n", folderPath, repsizes[i]);
338+
MsgAccept("\tShrinking '%s', now %d bytes\n", (char*)folderPath, repsizes[i]);
330339
}
331340
}
332341
else
@@ -358,15 +367,16 @@ void PackCutsceneFile(const char* foldername)
358367
MsgWarning("No chase replays\n");
359368
}
360369

361-
sprintf(folderPath, "%s_N.R", foldername);
370+
String folderPath = String::fromPrintf("%s_N.R", foldername);
371+
362372
FILE* wp = fopen(folderPath, "wb");
363373

364374
if (!wp)
365375
{
366376
for (int i = 0; i < MAX_FILE_CUTSCENES; i++)
367377
free(replays[i]);
368378

369-
MsgError("Unable to save '%s'\n", folderPath);
379+
MsgError("Unable to save '%s'\n", (char*)folderPath);
370380
return;
371381
}
372382

Driver2CutsceneTool/premake5.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ project "Driver2CutsceneTool"
55
language "C++"
66
compileas "C++"
77
targetdir "bin/%{cfg.buildcfg}"
8+
9+
-- framework link
10+
dependson { "frameworkLib", "libnstd" }
11+
links { "frameworkLib", "libnstd" }
12+
includedirs {
13+
"../dependencies/libnstd/include",
14+
}
15+
--
816

917
files {
1018
"**.cpp",
@@ -15,11 +23,6 @@ project "Driver2CutsceneTool"
1523
buildoptions {
1624
"-Wno-narrowing",
1725
"-fpermissive",
18-
"-m32"
19-
}
20-
21-
linkoptions {
22-
"-m32"
2326
}
2427

2528
filter "configurations:Debug"

Driver2MissionTool/mission_tool.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
#include <math.h>
1+
#include <stdlib.h>
2+
#include <string.h>
23

3-
#include <malloc.h>
4-
#include "core/VirtualStream.h"
54
#include "core/cmdlib.h"
6-
#include "math/dktypes.h"
7-
#include "util/image.h"
8-
#include "util/util.h"
9-
#include <string>
10-
#include <DriverLevelTool/driver_routines/d2_types.h>
11-
125
//----------------------------------------------------
136

147
void CompileMissionBlk(const char* filename)

Driver2MissionTool/premake5.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
project "Driver2MissionTool"
44
kind "ConsoleApp"
55
language "C++"
6-
compileas "C++"
76
targetdir "bin/%{cfg.buildcfg}"
87

8+
-- framework link
9+
dependson { "frameworkLib", "libnstd" }
10+
links { "frameworkLib", "libnstd" }
11+
includedirs {
12+
"../dependencies/libnstd/include",
13+
}
14+
--
15+
916
files {
1017
"**.cpp",
1118
"**.h",
@@ -15,11 +22,6 @@ project "Driver2MissionTool"
1522
buildoptions {
1623
"-Wno-narrowing",
1724
"-fpermissive",
18-
"-m32"
19-
}
20-
21-
linkoptions {
22-
"-m32"
2325
}
2426

2527
filter "configurations:Debug"

0 commit comments

Comments
 (0)