Skip to content

Commit 1e668c5

Browse files
committed
fixed build
1 parent cacf3a4 commit 1e668c5

File tree

7 files changed

+53
-164
lines changed

7 files changed

+53
-164
lines changed

.github/workflows/windows_release.yml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ jobs:
3838
run: |
3939
git fetch --all --tags -f
4040
41+
- name: Download JOM
42+
uses: suisei-cn/actions-download-file@v1
43+
with:
44+
url: http://download.qt.io/official_releases/jom/jom.zip
45+
target: ${{ runner.temp }}\
46+
47+
- name: Unzip JOM
48+
working-directory: ${{ runner.temp }}
49+
run: |
50+
7z x jom.zip -ojom
51+
4152
- name: Download zlib
4253
uses: suisei-cn/actions-download-file@v1
4354
with:
@@ -50,13 +61,6 @@ jobs:
5061
7z x zlib1213.zip -ozlib
5162
dir /w zlib
5263
53-
- name: compile zlib
54-
working-directory: ${{ runner.temp }}
55-
run: |
56-
cd zlib
57-
nmake /f win32/Makefile.msc
58-
dir /w
59-
6064
- name: Install Qt
6165
uses: jurplel/install-qt-action@v2
6266
with:
@@ -68,17 +72,6 @@ jobs:
6872
modules: qtcore qtwidgets qtgui #qtcharts qt3d
6973
setup-python: false
7074

71-
- name: Download JOM
72-
uses: suisei-cn/actions-download-file@v1
73-
with:
74-
url: http://download.qt.io/official_releases/jom/jom.zip
75-
target: ${{ runner.temp }}\
76-
77-
- name: Unzip JOM
78-
working-directory: ${{ runner.temp }}
79-
run: |
80-
7z x jom.zip -ojom
81-
8275
- name: Create build directory
8376
run: mkdir ${{ runner.temp }}\build
8477

@@ -87,10 +80,28 @@ jobs:
8780
with:
8881
arch: ${{ env.VSARCH }}
8982

83+
- name: compile zlib
84+
working-directory: ${{ runner.temp }}
85+
run: |
86+
cd zlib\\zlib-1.2.13
87+
dir /w
88+
nmake /f win32/Makefile.msc
89+
dir /w
90+
91+
mkdir ${{ runner.temp }}\build\libs
92+
mkdir ${{ runner.temp }}\build\headers
93+
copy zlib.lib ${{ runner.temp }}\build\libs
94+
copy zlib.h ${{ runner.temp }}\build\headers
95+
copy zconf.h ${{ runner.temp }}\build\headers
96+
97+
mkdir ${{ env.SOURCE_DIR }}\libs
98+
copy zlib.lib ${{ env.SOURCE_DIR }}\libs
99+
90100
- name: Build
91101
working-directory: ${{ runner.temp }}\build
92102
run: |
93103
qmake -r ${{ env.SOURCE_DIR }}\\mapedit.pro
104+
cat Makefile.Release
94105
${{ runner.temp }}\jom\jom -j2
95106
dir /s
96107
cd release

map.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ bool CMap::write(FILE *tfile)
135135
fwrite(&m_len, sizeof(uint8_t), 1, tfile);
136136
fwrite(&m_hei, sizeof(uint8_t), 1, tfile);
137137
fwrite(m_map, m_len * m_hei, 1, tfile);
138-
uint16_t attrCount = m_attrs.size();
139-
fwrite(&attrCount, sizeof(attrCount), 1, tfile);
138+
size_t attrCount = m_attrs.size();
139+
fwrite(&attrCount, sizeof(uint16_t), 1, tfile);
140140
for (auto& it: m_attrs) {
141141
uint16_t key = it.first;
142142
uint8_t x = key & 0xff;

mapedit.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CONFIG += c++17
88
# In order to do so, uncomment the following line.
99
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
1010

11-
INCLUDEPATH += shared/
11+
INCLUDEPATH += shared/ headers/
1212
DEFINES += USE_QFILE=1
1313

1414
SOURCES += \
@@ -69,3 +69,4 @@ RESOURCES += \
6969
mapedit.qrc
7070

7171
unix:LIBS += -lz
72+
win32:LIBS += -L"libs" -lzlib

shared/Frame.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,8 @@ void CFrame::enlarge()
962962

963963
void CFrame::shiftUP()
964964
{
965-
uint32_t t[m_nLen];
965+
966+
uint32_t *t = new uint32_t[m_nLen];
966967

967968
// copy first line to buffer
968969
memcpy(t, m_rgb, sizeof(uint32_t) * m_nLen);
@@ -975,11 +976,13 @@ void CFrame::shiftUP()
975976

976977
// copy first line to last
977978
memcpy(&at(0, m_nHei - 1), t, sizeof(uint32_t) * m_nLen);
979+
980+
delete []t;
978981
}
979982

980983
void CFrame::shiftDOWN()
981984
{
982-
uint32_t t[m_nLen];
985+
uint32_t *t = new uint32_t[m_nLen];
983986

984987
// copy first line to buffer
985988
memcpy(t, &at(0, m_nHei - 1), sizeof(uint32_t) * m_nLen);
@@ -992,6 +995,8 @@ void CFrame::shiftDOWN()
992995

993996
// copy first line to last
994997
memcpy(m_rgb, t, sizeof(uint32_t) * m_nLen);
998+
delete []t;
999+
9951000
}
9961001

9971002
void CFrame::shiftLEFT()

shared/FrameSet.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,8 +905,8 @@ void CFrameSet::toPng(unsigned char *&data, int &size)
905905
{
906906
if (m_size > 1)
907907
{
908-
short xx[m_size];
909-
short yy[m_size];
908+
short *xx = new short[m_size];
909+
short *yy = new short[m_size];
910910
int width = 0;
911911
int height = 0;
912912
for (int i = 0; i < m_size; ++i)
@@ -953,6 +953,8 @@ void CFrameSet::toPng(unsigned char *&data, int &size)
953953
frame->toPng(data, size, buf, t_size);
954954
delete frame;
955955
delete[] buf;
956+
delete []xx;
957+
delete []yy;
956958
}
957959
else
958960
{
@@ -986,10 +988,9 @@ void CFrameSet::setTag(const char *tag, const char *v)
986988
void CFrameSet::toSubset(CFrameSet &dest, int start, int end)
987989
{
988990
int last = end == -1 ? getSize() - 1 : end;
989-
CFrameSet &me = *this;
990991
for (int i = start; i <= last; ++i)
991992
{
992-
CFrame *p = new CFrame(me[i]);
993+
CFrame *p = new CFrame(m_arrFrames[i]);
993994
dest.add(p);
994995
}
995996
}

shared/helper.cpp

Lines changed: 8 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <string>
2323
#include <list>
2424
#include <zlib.h>
25-
//#include "FileWrap.h"
2625
#ifdef USE_QFILE
2726
#define FILEWRAP QFileWrap
2827
#include "../shared/qtgui/qfilewrap.h"
@@ -75,17 +74,19 @@ bool copyFile(const std::string in, const std::string out, std::string & errMsg)
7574
tfile.write(buf, size);
7675
tfile.close();
7776
} else {
78-
char tmp[out.length() + 128];
77+
char * tmp = new char[out.length() + 128];
7978
sprintf(tmp, "couldn't write: %s", out.c_str());
8079
errMsg = tmp;
8180
result = false;
81+
delete[] tmp;
8282
}
8383
delete [] buf;
8484
} else {
85-
char tmp[in.length() + 128];
85+
char * tmp = new char[in.length() + 128];
8686
sprintf(tmp, "couldn't read: %s", in.c_str());
8787
errMsg = tmp;
8888
result = false;
89+
delete []tmp;
8990
}
9091
return result;
9192
}
@@ -106,154 +107,25 @@ bool concat(const std::list<std::string> files, std::string out, std::string & m
106107
tfile.write(buf, size);
107108
delete [] buf;
108109
} else {
109-
char tmp[in.length() + 128];
110+
char *tmp = new char[in.length() + 128];
110111
sprintf(tmp, "couldn't read: %s", in.c_str());
111112
msg = tmp;
112113
result = false;
114+
delete []tmp;
113115
break;
114116
}
115117
}
116118
tfile.close();
117119
} else {
118-
char tmp[out.length() + 128];
120+
char *tmp = new char[out.length() + 128];
119121
sprintf(tmp, "couldn't write: %s", out.c_str());
120122
msg = tmp;
121123
result = false;
124+
delete []tmp;
122125
}
123126
return result;
124127
}
125128

126-
#ifdef _WIN32
127-
#include <windows.h>
128-
#include <limits.h>
129-
#include <errno.h>
130-
#include <sys/stat.h>
131-
132-
char *realpath(const char *path, char resolved_path[PATH_MAX])
133-
{
134-
char *return_path = 0;
135-
136-
if (path) //Else EINVAL
137-
{
138-
if (resolved_path)
139-
{
140-
return_path = resolved_path;
141-
}
142-
else
143-
{
144-
//Non standard extension that glibc uses
145-
return_path = (char*)malloc(PATH_MAX);
146-
}
147-
148-
if (return_path) //Else EINVAL
149-
{
150-
//This is a Win32 API function similar to what realpath() is supposed to do
151-
size_t size = GetFullPathNameA(path, PATH_MAX, return_path, 0);
152-
153-
//GetFullPathNameA() returns a size larger than buffer if buffer is too small
154-
if (size > PATH_MAX)
155-
{
156-
if (return_path != resolved_path) //Malloc'd buffer - Unstandard extension retry
157-
{
158-
size_t new_size;
159-
160-
free(return_path);
161-
return_path = (char*)malloc(size);
162-
163-
if (return_path)
164-
{
165-
new_size = GetFullPathNameA(path, size, return_path, 0); //Try again
166-
167-
if (new_size > size) //If it's still too large, we have a problem, don't try again
168-
{
169-
free(return_path);
170-
return_path = 0;
171-
errno = ENAMETOOLONG;
172-
}
173-
else
174-
{
175-
size = new_size;
176-
}
177-
}
178-
else
179-
{
180-
//I wasn't sure what to return here, but the standard does say to return EINVAL
181-
//if resolved_path is null, and in this case we couldn't malloc large enough buffer
182-
errno = EINVAL;
183-
}
184-
}
185-
else //resolved_path buffer isn't big enough
186-
{
187-
return_path = 0;
188-
errno = ENAMETOOLONG;
189-
}
190-
}
191-
192-
//GetFullPathNameA() returns 0 if some path resolve problem occured
193-
if (!size)
194-
{
195-
if (return_path != resolved_path) //Malloc'd buffer
196-
{
197-
free(return_path);
198-
}
199-
200-
return_path = 0;
201-
202-
//Convert MS errors into standard errors
203-
switch (GetLastError())
204-
{
205-
case ERROR_FILE_NOT_FOUND:
206-
errno = ENOENT;
207-
break;
208-
209-
case ERROR_PATH_NOT_FOUND: case ERROR_INVALID_DRIVE:
210-
errno = ENOTDIR;
211-
break;
212-
213-
case ERROR_ACCESS_DENIED:
214-
errno = EACCES;
215-
break;
216-
217-
default: //Unknown Error
218-
errno = EIO;
219-
break;
220-
}
221-
}
222-
223-
//If we get to here with a valid return_path, we're still doing good
224-
if (return_path)
225-
{
226-
struct stat stat_buffer;
227-
228-
//Make sure path exists, stat() returns 0 on success
229-
if (stat(return_path, &stat_buffer))
230-
{
231-
if (return_path != resolved_path)
232-
{
233-
free(return_path);
234-
}
235-
236-
return_path = 0;
237-
//stat() will set the correct errno for us
238-
}
239-
//else we succeeded!
240-
}
241-
}
242-
else
243-
{
244-
errno = EINVAL;
245-
}
246-
}
247-
else
248-
{
249-
errno = EINVAL;
250-
}
251-
252-
return return_path;
253-
}
254-
#else
255-
#endif
256-
257129
int compressData(unsigned char *in_data, unsigned long in_size, unsigned char **out_data, unsigned long & out_size)
258130
{
259131
out_size = ::compressBound(in_size);

shared/helper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ bool copyFile(const std::string in, const std::string out, std::string & errMsg)
2525
bool concat(const std::list<std::string> files, std::string out, std::string & msg);
2626
int upperClean(int c);
2727
#ifdef _WIN32
28-
char *realpath(const char *path, char resolved_path[PATH_MAX]);
2928
#else
3029
#include <stdlib.h>
3130
#include <linux/limits.h>

0 commit comments

Comments
 (0)