Batch #3903 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_18285 ParseHexString: logic confirmed by peer review Peer-reviewed-by: Yommy, youko, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). Adds to the build: Source/Utility/Text/HexString.cpp
45 lines
840 B
C++
45 lines
840 B
C++
#include "Utility/Text/HexString.h"
|
|
|
|
#include <cstring>
|
|
|
|
// OFFSET: 0x00AF9F80
|
|
// FUNCTION: fn_18285
|
|
int ParseHexString(const char* text) {
|
|
int value = 0;
|
|
unsigned char shift = 0;
|
|
for (int index = static_cast<int>(std::strlen(text)) - 1; index > 1; --index) {
|
|
const int digit = text[index];
|
|
switch (digit) {
|
|
case '0':
|
|
case '1':
|
|
case '2':
|
|
case '3':
|
|
case '4':
|
|
case '5':
|
|
case '6':
|
|
case '7':
|
|
case '8':
|
|
case '9':
|
|
value += (digit - '0') << shift;
|
|
break;
|
|
case 'A':
|
|
case 'B':
|
|
case 'C':
|
|
case 'D':
|
|
case 'E':
|
|
case 'F':
|
|
value += (digit - 'A' + 10) << shift;
|
|
break;
|
|
case 'a':
|
|
case 'b':
|
|
case 'c':
|
|
case 'd':
|
|
case 'e':
|
|
case 'f':
|
|
value += (digit - 'a' + 10) << shift;
|
|
break;
|
|
}
|
|
shift += 4;
|
|
}
|
|
return value;
|
|
}
|