Mercurial > mm7
annotate ErrorHandling.h @ 1857:f357e4cbd169
Actor::AI_SpellAttack moved spells into a huge case
author | Grumpy7 |
---|---|
date | Mon, 14 Oct 2013 00:58:05 +0200 |
parents | 30db6d265ceb |
children | aff7a7b072b7 |
rev | line source |
---|---|
1545 | 1 #pragma once |
2 | |
3 #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
|
4 #define Assert(condition, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, __VA_ARGS__) |
1545 | 5 |
6 | |
7 | |
8 #include <stdarg.h> | |
9 inline __declspec(noreturn) void Error_impl_(const char *filename, const char *functionname, int line, | |
10 const char *format, ...) | |
11 { | |
12 va_list va; | |
13 va_start(va, format); | |
14 { | |
15 char header[4096]; | |
16 sprintf(header, "Error in %s: %u\n\t%s\n\n", filename, line, functionname); | |
17 | |
18 char msg_body[8192]; | |
19 vsprintf(msg_body, format, va); | |
20 | |
21 wchar_t msg[sizeof(header) + sizeof(msg_body)]; | |
22 swprintf(msg, L"%S %S", header, msg_body); | |
23 | |
24 extern void MsgBox(const wchar_t *, const wchar_t *); | |
25 MsgBox(msg, L"Error"); | |
26 } | |
27 va_end(va); | |
28 | |
29 __debugbreak(); | |
30 } | |
31 | |
32 | |
33 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
|
34 bool condition, const char *condition_string, const char *format = nullptr, ...) |
1545 | 35 { |
36 if (condition) | |
37 return; | |
38 | |
39 va_list va; | |
40 va_start(va, format); | |
41 { | |
42 char header[4096]; | |
43 sprintf(header, "Assertion in %s: %u\n\t%s:\n%s\n\n", filename, line, functionname, condition_string); | |
44 | |
45 char msg_body[8192]; | |
46 vsprintf(msg_body, format, va); | |
47 | |
48 wchar_t msg[sizeof(header) + sizeof(msg_body)]; | |
49 if (format) | |
50 swprintf(msg, L"%S %S", header, msg_body); | |
51 else | |
52 swprintf(msg, L"%S", header); | |
53 | |
54 extern void MsgBox(const wchar_t *, const wchar_t *); | |
55 MsgBox(msg, L"Assertion"); | |
56 } | |
57 va_end(va); | |
58 | |
59 __debugbreak(); | |
60 } |