summaryrefslogtreecommitdiffstats
path: root/src/core/obrstr.cpp
blob: 3663d1347833944b9bf89124c2f7d9a98e321670 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "common.h"
#include "Debug.h"
#include "obrstr.h"

char obrstr[128];
char obrstr2[128];

void ObrInt(int32 n1)
{
	IntToStr(n1, obrstr);
	CDebug::DebugAddText(obrstr);
}

void ObrInt2(int32 n1, int32 n2)
{
	IntToStr(n1, obrstr);
	strcat(obrstr, "  ");
	IntToStr(n2, obrstr2);
	strcat(obrstr, obrstr2);
	CDebug::DebugAddText(obrstr);
}

void ObrInt3(int32 n1, int32 n2, int32 n3)
{
	IntToStr(n1, obrstr);
	strcat(obrstr, "  ");
	IntToStr(n2, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n3, obrstr2);
	strcat(obrstr, obrstr2);
	CDebug::DebugAddText(obrstr);
}

void ObrInt4(int32 n1, int32 n2, int32 n3, int32 n4)
{
	IntToStr(n1, obrstr);
	strcat(obrstr, "  ");
	IntToStr(n2, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n3, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n4, obrstr2);
	strcat(obrstr, obrstr2);
	CDebug::DebugAddText(obrstr);
}

void ObrInt5(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5)
{
	IntToStr(n1, obrstr);
	strcat(obrstr, "  ");
	IntToStr(n2, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n3, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n4, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n5, obrstr2);
	strcat(obrstr, obrstr2);
	CDebug::DebugAddText(obrstr);
}

void ObrInt6(int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
{
	IntToStr(n1, obrstr);
	strcat(obrstr, "  ");
	IntToStr(n2, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n3, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n4, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n5, obrstr2);
	strcat(obrstr, obrstr2);
	strcat(obrstr, "  ");
	IntToStr(n6, obrstr2);
	strcat(obrstr, obrstr2);
	CDebug::DebugAddText(obrstr);
}

void IntToStr(int32 inNum, char *outStr)
{
	bool isNeg = inNum < 0;

	if (isNeg) {
		inNum = -inNum;
		*outStr = '-';
	}

	int16 digits = 1;

	if (inNum > 9) {
		int32 _inNum = inNum;
		do {
			digits++;
			_inNum /= 10;
		} while (_inNum > 9);
	}

	int32 strSize = digits;
	if (isNeg)
		strSize++;

	char *pStr = &outStr[strSize];
	int32 i = 0;
	do {
		*(pStr-- - 1) = (inNum % 10) + '0';
		inNum /= 10;
	} while (++i < strSize);
	outStr[strSize] = '\0';
}