Skip to content

Commit 685cb66

Browse files
author
nitrocaster
committed
Merge branch 'ai_cleanup' of github.com:OpenXRay/xray-16 into ai_cleanup
2 parents dd659f9 + c9d84c1 commit 685cb66

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

src/xrCore/Crypto/xr_dsa_signer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ shared_str const xr_dsa_signer::sign_mt(u8 const * data,
4242
return m_dsa.sign (m_private_key, m_sha.pointer(), m_sha.digest_length);
4343
}
4444

45-
char const * current_time(string64 & dest_time)
45+
char *current_time(string64 &dest_time)
4646
{
47-
time_t tmp_curr_time;
48-
49-
dest_time[0] = 0;
50-
_time64 (&tmp_curr_time);
51-
tm* tmp_tm = _localtime64(&tmp_curr_time);
47+
const time_t tmp_curr_time = std::time(nullptr);
48+
tm *tmp_tm = std::localtime(&tmp_curr_time);
5249

5350
xr_sprintf(dest_time, sizeof(dest_time),
5451
"%02d.%02d.%d_%02d:%02d:%02d",

src/xrCore/Crypto/xr_dsa_signer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ class XRCORE_API xr_dsa_signer
2828

2929
}; //xr_dsa_signer
3030

31-
XRCORE_API char const * current_time(string64 & dest_time);
31+
XRCORE_API char *current_time(string64 &dest_time);
3232

33-
#endif //#ifndef XR_DSA_SIGNER_INCLUDED
33+
#endif //#ifndef XR_DSA_SIGNER_INCLUDED

src/xrCore/Threading/Lock.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class XRCORE_API Lock
2020
{
2121
public:
2222
#ifdef CONFIG_PROFILE_LOCKS
23-
Lock(const char *id) : isLocked(false), id(id) {}
23+
Lock(const char *id) : lockCounter(0), id(id) {}
2424
#else
25-
Lock() : isLocked(false) {}
25+
Lock() : lockCounter(0) {}
2626
#endif
2727

2828
Lock(const Lock &) = delete;
@@ -34,29 +34,29 @@ class XRCORE_API Lock
3434
void Enter()
3535
{
3636
mutex.lock();
37-
isLocked = true;
37+
lockCounter++;
3838
}
3939
#endif
4040

4141
bool TryEnter()
4242
{
4343
bool locked = mutex.try_lock();
4444
if (locked)
45-
isLocked = true;
45+
lockCounter++;
4646
return locked;
4747
}
4848

4949
void Leave()
5050
{
5151
mutex.unlock();
52-
isLocked = false;
52+
lockCounter--;
5353
}
5454

55-
bool IsLocked() const { return isLocked; }
55+
bool IsLocked() const { return lockCounter; }
5656

5757
private:
5858
std::recursive_mutex mutex;
59-
std::atomic_bool isLocked;
59+
std::atomic_int lockCounter;
6060
#ifdef CONFIG_PROFILE_LOCKS
6161
const char *id;
6262
#endif

src/xrCore/xrstring.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "FS_impl.h"
77

88
XRCORE_API extern str_container* g_pStringContainer = NULL;
9-
#define HEADER 16 // ref + len + crc + next
109

1110
#if 1
1211

@@ -153,7 +152,7 @@ str_value* str_container::dock(str_c value)
153152
// calc len
154153
u32 s_len = xr_strlen(value);
155154
u32 s_len_with_zero = (u32)s_len + 1;
156-
VERIFY(HEADER + s_len_with_zero < 4096);
155+
VERIFY(sizeof(str_value) + s_len_with_zero < 4096);
157156

158157
// setup find structure
159158
char header[sizeof(str_value)];
@@ -177,7 +176,7 @@ str_value* str_container::dock(str_c value)
177176
)
178177
{
179178

180-
result = (str_value*)Memory.mem_alloc(HEADER + s_len_with_zero
179+
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
181180
#ifdef DEBUG_MEMORY_NAME
182181
, "storage: sstring"
183182
#endif // DEBUG_MEMORY_NAME
@@ -294,7 +293,7 @@ str_value* str_container::dock(str_c value)
294293
// calc len
295294
u32 s_len = xr_strlen(value);
296295
u32 s_len_with_zero = (u32)s_len + 1;
297-
VERIFY(HEADER + s_len_with_zero < 4096);
296+
VERIFY(sizeof(str_value) + s_len_with_zero < 4096);
298297
299298
// setup find structure
300299
char header[sizeof(str_value)];
@@ -328,7 +327,7 @@ str_value* str_container::dock(str_c value)
328327
// Insert string
329328
// DUMP_PHASE;
330329
331-
result = (str_value*)Memory.mem_alloc(HEADER + s_len_with_zero
330+
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
332331
#ifdef DEBUG_MEMORY_NAME
333332
, "storage: sstring"
334333
#endif // DEBUG_MEMORY_NAME
@@ -423,7 +422,7 @@ u32 str_container::stat_economy()
423422
const int node_size = 20;
424423
for (; it != end; it++)
425424
{
426-
counter -= HEADER;
425+
counter -= sizeof(str_value);
427426
counter -= node_size;
428427
counter += int((int((*it)->dwReference) - 1)*int((*it)->dwLength + 1));
429428
}

src/xrEngine/xrLoadSurface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ void Surface_Init()
8787
BOOL Surface_Detect(string_path& F, LPSTR N)
8888
{
8989
FS.update_path(F, "$game_textures$", strconcat(sizeof(F), F, N, ".dds"));
90-
int h = _open(F, O_RDONLY | O_BINARY);
91-
if (h > 0)
90+
FILE *file = fopen(F, "rb");
91+
if (file)
9292
{
93-
_close(h);
93+
fclose(file);
9494
return (TRUE);
9595
}
9696

0 commit comments

Comments
 (0)