Skip to content
This repository was archived by the owner on Dec 27, 2020. It is now read-only.

Commit 0c07c27

Browse files
committed
TOOLS: Make lab.{h,cpp} detect if it is a Grim or EMI lab and move them in tools/.
1 parent 76e2321 commit 0c07c27

File tree

8 files changed

+21
-14
lines changed

8 files changed

+21
-14
lines changed

tools/emi/animb2txt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <string>
2222
#include <iostream>
2323
#include "filetools.h"
24-
#include "lab.h"
24+
#include "tools/lab.h"
2525

2626
using namespace std;
2727

tools/emi/meshb2obj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <string>
2020
#include <iostream>
2121
#include "filetools.h"
22-
#include "lab.h"
22+
#include "tools/lab.h"
2323

2424
int main(int argc, char **argv) {
2525
if (argc < 2) {

tools/emi/setb2set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <fstream>
1212
#include <vector>
1313
#include <sstream>
14-
#include "lab.h"
14+
#include "tools/lab.h"
1515

1616
using namespace std;
1717

tools/emi/sklb2txt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <string>
33
#include <iostream>
44
#include "filetools.h"
5-
#include "lab.h"
5+
#include "tools/lab.h"
66
// Based on Benjamin Haischs work on sklb-files.
77

88
using namespace std;

tools/emi/til2bmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <cstdio>
2727
#include <cstring>
2828
#include "common/endian.h"
29-
#include "lab.h"
29+
#include "tools/lab.h"
3030

3131
/*
3232
This tool converts EMI-TILEs into BMP-files, and supports both the format used in the Windows

tools/emi/lab.cpp renamed to tools/lab.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ uint32 READ_LE_UINT32(const void *ptr) {
3636
}
3737

3838
void Lab::Load(std::string filename) {
39-
g_type = GT_EMI; // FIXME, detect game-type properly.
40-
4139
infile = fopen(filename.c_str(), "rb");
4240
if (infile == 0) {
4341
std::cout << "Can not open source file: " << filename << std::endl;
@@ -49,8 +47,17 @@ void Lab::Load(std::string filename) {
4947
uint32 num, s_size, s_offset;
5048
fread(&num, 1, 4, infile);
5149
fread(&s_size, 1, 4, infile);
52-
if(g_type == GT_EMI)
53-
fread(&s_offset,1,4,infile);
50+
51+
uint32 typeTest = 0;
52+
fread(&typeTest, 1, 4, infile);
53+
if (typeTest == 0) { // First entry of the table has offset 0 for Grim
54+
g_type = GT_GRIM;
55+
fseek(infile, -4, SEEK_CUR);
56+
} else { // EMI has an offset instead.
57+
s_offset = typeTest;
58+
g_type = GT_EMI;
59+
}
60+
5461
head.num_entries = READ_LE_UINT32(&num);
5562
head.string_table_size = READ_LE_UINT32(&s_size);
5663
if (0 != memcmp(&head.magic, "LABN", 4)) {
File renamed without changes.

tools/module.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,27 @@ TOOL_OBJS := emi/cosb2cos.o
7272
include $(srcdir)/rules.mk
7373

7474
TOOL := meshb2obj
75-
TOOL_OBJS := emi/meshb2obj.o emi/lab.o
75+
TOOL_OBJS := emi/meshb2obj.o lab.o
7676
include $(srcdir)/rules.mk
7777

7878
TOOL := animb2txt
79-
TOOL_OBJS := emi/animb2txt.o emi/lab.o
79+
TOOL_OBJS := emi/animb2txt.o lab.o
8080
include $(srcdir)/rules.mk
8181

8282
TOOL := setb2set
83-
TOOL_OBJS := emi/setb2set.o emi/lab.o
83+
TOOL_OBJS := emi/setb2set.o lab.o
8484
include $(srcdir)/rules.mk
8585

8686
TOOL := sklb2txt
87-
TOOL_OBJS := emi/sklb2txt.o emi/lab.o
87+
TOOL_OBJS := emi/sklb2txt.o lab.o
8888
include $(srcdir)/rules.mk
8989

9090
TOOL := set2fig
9191
TOOL_OBJS := set2fig.o
9292
include $(srcdir)/rules.mk
9393

9494
TOOL := til2bmp
95-
TOOL_OBJS := emi/til2bmp.o emi/lab.o
95+
TOOL_OBJS := emi/til2bmp.o lab.o
9696
TOOL_LDFLAGS := -lz
9797
include $(srcdir)/rules.mk
9898

0 commit comments

Comments
 (0)