annotate ErrorHandling.h @ 2293:b0f10ef66e00

stru319::CalcMagicalDamageToActor moved to Actor class
author Grumpy7
date Sun, 16 Mar 2014 19:42:29 +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
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
2 #pragma once
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
3
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
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
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
6
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
7
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
8
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
9 #include <stdarg.h>
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
10 inline __declspec(noreturn) void Error_impl_(const char *filename, const char *functionname, int line,
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
11 const char *format, ...)
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
12 {
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
13 va_list va;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
14 va_start(va, format);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
15 {
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
16 char header[4096];
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
17 sprintf(header, "Error in %s: %u\n\t%s\n\n", filename, line, functionname);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
18
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
19 char msg_body[8192];
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
20 vsprintf(msg_body, format, va);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
21
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
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
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
24
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
25 extern void MsgBox(const wchar_t *, const wchar_t *);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
26 MsgBox(msg, L"Error");
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
27 }
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
28 va_end(va);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
29
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
30 __debugbreak();
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
31 }
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
32
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
33
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
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
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
36 {
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
37 if (condition)
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
38 return;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
39
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
40 va_list va;
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
41 va_start(va, format);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
42 {
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
43 char header[4096];
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
44 sprintf(header, "Assertion in %s: %u\n\t%s:\n%s\n\n", filename, line, functionname, condition_string);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
45
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
46 char msg_body[8192];
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
47 vsprintf(msg_body, format, va);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
48
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
49 wchar_t msg[sizeof(header) + sizeof(msg_body)];
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
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
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
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
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
54
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
55 extern void MsgBox(const wchar_t *, const wchar_t *);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
56 MsgBox(msg, L"Assertion");
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
57 }
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
58 va_end(va);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
59
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
60 __debugbreak();
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents:
diff changeset
61 }