Skip to content

Commit 414fcdb

Browse files
author
Pavel Kovalenko
committed
Merge branch 'dev'.
2 parents 5edf937 + 7f03b30 commit 414fcdb

File tree

17 files changed

+108
-110
lines changed

17 files changed

+108
-110
lines changed

doc/design/task_list.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ nitrocaster: Pavel Kovalenko
3434
- decouple hxGrid
3535
- bugs/issues
3636
- generic
37-
- stackoverflow when starting with too long command line
38-
- stackoverflow when game directory contains too many files (_alloca)
37+
+ stackoverflow when game directory contains too many files (_alloca)
38+
+ partially fixed by loxotron
3939
- can me improved (get rid of recursive directory traversal)
40-
- exclude $app_data_root$/logs and $app_data_root$/screenshots from index
41-
- GetColorFromText bug
40+
c exclude $app_data_root$/logs and $app_data_root$/screenshots from index
41+
+ don't scan directory if it contains .xrignore file.
42+
+ GetColorFromText bug
4243
- (bytes_need<=mSize) && vl_Count
43-
- "! tab named [1] doesnt exist"
44+
+ "! tab named [1] doesnt exist"
4445
- UI
45-
- clip cursor in windowed mode with enabled input capture
46+
+ clip cursor in windowed mode with enabled input capture
4647
- dragging music volume slider doesn't make any effect until one presses 'Apply' button
48+
? save MP settings
4749
- core
48-
- buffer overflow when copying command line to Core.Params
50+
+ buffer overflow when copying command line to Core.Params
4951
- misplaced arguments in calls to xrDebug::backend
5052
- multiplayer
51-
- xrGameSpy: fix master server name (gamespy is down)
53+
+ xrGameSpy: fix master server name (gamespy is down)
5254
- dedicated server
5355
- vulnerabilities (verify)
5456
c dirtysky
@@ -74,7 +76,6 @@ nitrocaster: Pavel Kovalenko
7476
- UI
7577
- close sleep dialog by ESC key
7678
- multiplayer
77-
- use GSC server instead of GameSpy one
7879
- ipv6 support
7980
- get rid of DirectPlay
8081
- log suspicious packets and kick/ban its senders after X attempts

doc/procedure/cpp_code.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,22 @@ Casing styles:
433433
- Global variables: PascalCase
434434
- Namespaces: PascalCase
435435

436+
When overriding virtual function, use override specifier on function declaration.
437+
BAD
438+
class Server : public IServer
439+
{
440+
...
441+
virtual void OnClientConnected(IClient* client);
442+
...
443+
};
444+
GOOD
445+
class Server : public IServer
446+
{
447+
...
448+
virtual void OnClientConnected(IClient* client) override;
449+
...
450+
};
451+
436452
Checking function return values:
437453
Functions that return bool or a pointer will be checked without
438454
comparing, if they return true or false.

src/Layers/xrRender/Texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ ID3DBaseTexture* CRender::texture_load(LPCSTR fRName, u32& ret_msize)
330330
D3DXIMAGE_INFO IMG;
331331
S = FS.r_open (fn);
332332
#ifdef DEBUG
333-
Msg ("* Loaded: %s[%d]b",fn,S->length());
333+
Msg ("* Loaded: %s[%d]",fn,S->length());
334334
#endif // DEBUG
335335
img_size = S->length ();
336336
R_ASSERT (S);

src/Layers/xrRenderDX10/dx10Texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ ID3DBaseTexture* CRender::texture_load(LPCSTR fRName, u32& ret_msize, bool bStag
353353

354354
S = FS.r_open (fn);
355355
#ifdef DEBUG
356-
Msg ("* Loaded: %s[%d]b",fn,S->length());
356+
Msg ("* Loaded: %s[%d]",fn,S->length());
357357
#endif // DEBUG
358358
img_size = S->length ();
359359
R_ASSERT (S);

src/xrCore/LocatorAPI.cpp

Lines changed: 52 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -494,29 +494,27 @@ bool CLocatorAPI::load_all_unloaded_archives()
494494
}
495495

496496

497-
void CLocatorAPI::ProcessOne(LPCSTR path, void* _F)
497+
void CLocatorAPI::ProcessOne(LPCSTR path, const _finddata_t& entry)
498498
{
499-
_finddata_t& F = *((_finddata_t*)_F);
500-
501499
string_path N;
502500
xr_strcpy (N,sizeof(N),path);
503-
xr_strcat (N,F.name);
501+
xr_strcat (N,entry.name);
504502
xr_strlwr (N);
505503

506-
if (F.attrib&_A_HIDDEN) return;
504+
if (entry.attrib&_A_HIDDEN) return;
507505

508-
if (F.attrib&_A_SUBDIR) {
506+
if (entry.attrib&_A_SUBDIR) {
509507
if (bNoRecurse) return;
510-
if (0==xr_strcmp(F.name,".")) return;
511-
if (0==xr_strcmp(F.name,"..")) return;
508+
if (0==xr_strcmp(entry.name,".")) return;
509+
if (0==xr_strcmp(entry.name,"..")) return;
512510
xr_strcat (N,"\\");
513-
Register (N,0xffffffff,0,0,F.size,F.size,(u32)F.time_write);
511+
Register (N,0xffffffff,0,0,entry.size,entry.size,(u32)entry.time_write);
514512
Recurse (N);
515513
} else {
516514
if (strext(N) && (0==strncmp(strext(N),".db",3) || 0==strncmp(strext(N),".xdb",4)) )
517515
ProcessArchive (N);
518516
else
519-
Register (N,0xffffffff,0,0,F.size,F.size,(u32)F.time_write);
517+
Register (N,0xffffffff,0,0,entry.size,entry.size,(u32)entry.time_write);
520518
}
521519
}
522520

@@ -551,66 +549,51 @@ bool ignore_path(const char* _path){
551549

552550
bool CLocatorAPI::Recurse (const char* path)
553551
{
554-
_finddata_t sFile;
555-
intptr_t hFile;
556-
557-
string_path N;
558-
xr_strcpy (N,sizeof(N),path);
559-
xr_strcat (N,"*.*");
560-
561-
rec_files.reserve(1224);
562-
563-
// find all files
564-
if (-1==(hFile=_findfirst(N, &sFile)))
565-
{
566-
// Log ("! Wrong path: ",path);
567-
return false;
552+
string_path scanPath;
553+
xr_strcpy(scanPath, sizeof(scanPath), path);
554+
xr_strcat(scanPath, ".xrignore");
555+
struct stat buffer;
556+
if (!stat(scanPath, &buffer))
557+
return true;
558+
xr_strcpy(scanPath, sizeof(scanPath), path);
559+
xr_strcat(scanPath, "*.*");
560+
_finddata_t findData;
561+
intptr_t handle = _findfirst(scanPath, &findData);
562+
if (handle == -1)
563+
return false;
564+
rec_files.reserve(256);
565+
size_t oldSize = rec_files.size();
566+
intptr_t done = handle;
567+
while (done != -1)
568+
{
569+
string1024 fullPath;
570+
bool ignore = false;
571+
if (m_Flags.test(flNeedCheck))
572+
{
573+
xr_strcpy(fullPath, sizeof(fullPath), path);
574+
xr_strcat(fullPath, findData.name);
575+
ignore = ignore_name(findData.name) || ignore_path(fullPath);
576+
}
577+
else
578+
{
579+
ignore = ignore_name(findData.name);
580+
}
581+
if (!ignore)
582+
rec_files.push_back(findData);
583+
done = _findnext(handle, &findData);
568584
}
569-
570-
string1024 full_path;
571-
if (m_Flags.test(flNeedCheck))
572-
{
573-
xr_strcpy(full_path,sizeof(full_path), path);
574-
xr_strcat(full_path, sFile.name);
575-
576-
// çàãîíÿåì â âåêòîð äëÿ òîãî *.db* ïðèõîäèëè â ñîðòèðîâàííîì ïîðÿäêå
577-
if(!ignore_name(sFile.name) && !ignore_path(full_path))
578-
rec_files.push_back(sFile);
579-
580-
while ( _findnext( hFile, &sFile ) == 0 )
581-
{
582-
xr_strcpy(full_path,sizeof(full_path), path);
583-
xr_strcat(full_path, sFile.name);
584-
if(!ignore_name(sFile.name) && !ignore_path(full_path))
585-
rec_files.push_back(sFile);
586-
}
587-
}
588-
else
589-
{
590-
// çàãîíÿåì â âåêòîð äëÿ òîãî *.db* ïðèõîäèëè â ñîðòèðîâàííîì ïîðÿäêå
591-
if(!ignore_name(sFile.name))
592-
rec_files.push_back(sFile);
593-
594-
while ( _findnext( hFile, &sFile ) == 0 )
595-
{
596-
if(!ignore_name(sFile.name))
597-
rec_files.push_back(sFile);
598-
}
599-
600-
}
601-
602-
_findclose ( hFile );
603-
604-
FFVec buffer(rec_files);
605-
rec_files.clear_not_free();
606-
std::sort (buffer.begin(), buffer.end(), pred_str_ff);
607-
for (FFIt I = buffer.begin(), E = buffer.end(); I != E; ++I)
608-
ProcessOne (path, &*I);
609-
610-
// insert self
611-
if (path&&path[0])\
612-
Register (path,0xffffffff,0,0,0,0,0);
613-
585+
_findclose(handle);
586+
size_t newSize = rec_files.size();
587+
if (newSize > oldSize)
588+
{
589+
std::sort(rec_files.begin()+oldSize, rec_files.end(), pred_str_ff);
590+
for (size_t i = oldSize; i < newSize; i++)
591+
ProcessOne(path, rec_files[i]);
592+
rec_files.erase(rec_files.begin()+oldSize, rec_files.end());
593+
}
594+
// insert self
595+
if (path && path[0] != 0)
596+
Register(path, 0xffffffff, 0, 0, 0, 0, 0);
614597
return true;
615598
}
616599

src/xrCore/LocatorAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class XRCORE_API CLocatorAPI
6969

7070
void Register (LPCSTR name, u32 vfs, u32 crc, u32 ptr, u32 size_real, u32 size_compressed, u32 modif);
7171
void ProcessArchive (LPCSTR path);
72-
void ProcessOne (LPCSTR path, void* F);
72+
void ProcessOne (LPCSTR path, const _finddata_t& entry);
7373
bool Recurse (LPCSTR path);
7474

7575
files_it file_find_it (LPCSTR n);

src/xrCore/xrCore.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ void xrCore::_initialize (LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs,
4141
#endif
4242
// Init COM so we can use CoCreateInstance
4343
// HRESULT co_res =
44-
if (!strstr(GetCommandLine(),"-editor"))
44+
Params = xr_strdup(GetCommandLine());
45+
xr_strlwr(Params);
46+
if (!strstr(Params, "-editor"))
4547
CoInitializeEx (NULL, COINIT_MULTITHREADED);
4648

47-
xr_strcpy (Params,sizeof(Params),GetCommandLine());
48-
_strlwr_s (Params,sizeof(Params));
49-
5049
string_path fn,dr,di;
5150

5251
// application path
@@ -118,7 +117,6 @@ void xrCore::_initialize (LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs,
118117
EFS._initialize ();
119118
#ifdef DEBUG
120119
#ifndef _EDITOR
121-
Msg ("CRT heap 0x%08x",_get_heap_handle());
122120
Msg ("Process heap 0x%08x",GetProcessHeap());
123121
#endif
124122
#endif // DEBUG
@@ -147,7 +145,7 @@ void xrCore::_destroy ()
147145
xr_delete (trained_model);
148146
}
149147
#endif
150-
148+
xr_free(Params);
151149
Memory._destroy ();
152150
}
153151
}

src/xrCore/xrCore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class XRCORE_API xrCore
299299
string_path WorkingPath;
300300
string64 UserName;
301301
string64 CompName;
302-
string512 Params;
302+
char* Params;
303303
DWORD dwFrame;
304304

305305
public:

src/xrEngine/x_ray.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,8 +1556,10 @@ void doBenchmark(LPCSTR name)
15561556
xr_strcpy (g_sBenchmarkName, test_name);
15571557

15581558
test_command = ini.r_string_wb("benchmark",test_name);
1559-
xr_strcpy (Core.Params,*test_command);
1560-
_strlwr_s (Core.Params);
1559+
u32 cmdSize = test_command.size()+1;
1560+
Core.Params = (char*)xr_realloc(Core.Params, cmdSize);
1561+
xr_strcpy(Core.Params, cmdSize, test_command.c_str());
1562+
xr_strlwr(Core.Params);
15611563

15621564
InitInput ();
15631565
if(i){

src/xrEngine/xrSASH.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ void xrSASH::LoopNative()
136136
//xr_strcpy(g_sBenchmarkName, test_name);
137137

138138
test_command = ini.r_string_wb("benchmark",test_name);
139-
xr_strcpy( Core.Params, *test_command );
140-
_strlwr_s( Core.Params );
139+
u32 cmdSize = test_command.size()+1;
140+
Core.Params = (char*)xr_realloc(Core.Params, cmdSize);
141+
xr_strcpy(Core.Params, cmdSize, test_command.c_str());
142+
xr_strlwr(Core.Params);
141143

142144
RunBenchmark(test_name);
143145

0 commit comments

Comments
 (0)