Mercurial > mm7
annotate ErrorHandling.h @ 2258:01d7e9ec51e6
sub_410D99_get_map_index cleaned up
author | Grumpy7 |
---|---|
date | Mon, 03 Mar 2014 23:49:23 +0100 |
parents | aff7a7b072b7 |
children | d6887ee81068 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
1558
diff
changeset
|
1 #define _CRT_NON_CONFORMING_SWPRINTFS |
1545 | 2 #pragma once |
3 | |
4 #define Error(format, ...) Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__) | |
1558
30db6d265ceb
Changed the new Assert macro definition slightly, Party::AddItem (for some reason in players.cpp) renamed to Party::AddItemToParty, cleaned up; some unused variables in previous functions removed
Grumpy7
parents:
1545
diff
changeset
|
5 #define Assert(condition, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, __VA_ARGS__) |
1545 | 6 |
7 | |
8 | |
9 #include <stdarg.h> | |
10 inline __declspec(noreturn) void Error_impl_(const char *filename, const char *functionname, int line, | |
11 const char *format, ...) | |
12 { | |
13 va_list va; | |
14 va_start(va, format); | |
15 { | |
16 char header[4096]; | |
17 sprintf(header, "Error in %s: %u\n\t%s\n\n", filename, line, functionname); | |
18 | |
19 char msg_body[8192]; | |
20 vsprintf(msg_body, format, va); | |
21 | |
22 wchar_t msg[sizeof(header) + sizeof(msg_body)]; | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
1558
diff
changeset
|
23 swprintf(msg, 8192, L"%S %S", header, msg_body); |
1545 | 24 |
25 extern void MsgBox(const wchar_t *, const wchar_t *); | |
26 MsgBox(msg, L"Error"); | |
27 } | |
28 va_end(va); | |
29 | |
30 __debugbreak(); | |
31 } | |
32 | |
33 | |
34 inline void Assert_impl_(const char *filename, const char *functionname, int line, | |
1558
30db6d265ceb
Changed the new Assert macro definition slightly, Party::AddItem (for some reason in players.cpp) renamed to Party::AddItemToParty, cleaned up; some unused variables in previous functions removed
Grumpy7
parents:
1545
diff
changeset
|
35 bool condition, const char *condition_string, const char *format = nullptr, ...) |
1545 | 36 { |
37 if (condition) | |
38 return; | |
39 | |
40 va_list va; | |
41 va_start(va, format); | |
42 { | |
43 char header[4096]; | |
44 sprintf(header, "Assertion in %s: %u\n\t%s:\n%s\n\n", filename, line, functionname, condition_string); | |
45 | |
46 char msg_body[8192]; | |
47 vsprintf(msg_body, format, va); | |
48 | |
49 wchar_t msg[sizeof(header) + sizeof(msg_body)]; | |
50 if (format) | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
1558
diff
changeset
|
51 swprintf(msg, (sizeof(header) + sizeof(msg_body)), L"%S %S", header, msg_body); |
1545 | 52 else |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
1558
diff
changeset
|
53 swprintf(msg, (sizeof(header) + sizeof(msg_body)), L"%S", header); |
1545 | 54 |
55 extern void MsgBox(const wchar_t *, const wchar_t *); | |
56 MsgBox(msg, L"Assertion"); | |
57 } | |
58 va_end(va); | |
59 | |
60 __debugbreak(); | |
61 } |