annotate Engine/stuff.h @ 2511:fb1c61a82a55

uHouseID - 1
author Ritor1
date Thu, 02 Oct 2014 17:35:50 +0600
parents 68cdef6879a0
children a902abdfc7f2
rev   line source
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1 #pragma once
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2 #include <windows.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
3 #include <stdio.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
6
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
7 inline void Assert(bool condition, const char *format, ...)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
8 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
9 if (condition)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
10 return;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
11
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
12 va_list va;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
13 va_start(va, format);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
14 char msg[4096];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
15 vsprintf(msg, format, va);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
16 MessageBoxA(nullptr, msg, "Assert", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
17 va_end(va);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
18
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
19 __debugbreak();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
20 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
21
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
22 inline void Error(const char *format, ...)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
23 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
24 va_list va;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
25 va_start(va, format);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
26 char msg[4096];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
27 vsprintf(msg, format, va);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
28 MessageBoxA(nullptr, msg, "Error", 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
29 va_end(va);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
31 __debugbreak();
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
32 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
33
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
34
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
35
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
36 inline void log(char *format, ...)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
37 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
38 va_list va;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
39 va_start(va, format);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
40 char msg[256];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
41 vsprintf(msg, format, va);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
42 va_end(va);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
43 DWORD w;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
44
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
45 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, strlen(msg), &w, 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
46 }