Files
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

100 lines
2.9 KiB
C++

// FastMath.h: interface for the CFastMath class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _CUSTOM_MATH_FUNCTIONS_H_
#define _CUSTOM_MATH_FUNCTIONS_H_
#include <winsock2.h>
#include <windows.h>
#include <cmath>
namespace Math
{
namespace Convert
{
extern const unsigned short m_FastHeToBi[0x100];
// SPX, IPX 주소 계산을 위해 사용하는 함수
inline TCHAR BiToHe(TCHAR cBin);
inline void AcToHe(char *szDst, char *szSrc, int iCount);
// String을 값으로 바꿈(String은 0x가 붙은 Hex string이다.)
inline BYTE StrToHex08(const TCHAR *szSrc);
inline WORD StrToHex16(const TCHAR *szSrc);
inline unsigned long StrToHex32(const TCHAR *szSrc);
inline DWORD64 StrToHex64(const TCHAR *szSrc);
// String을 값으로 바꿈(0x가 붙던지, 붙지 않던지간에 전부 바꿀 수 있다)
inline BYTE Atoc(const TCHAR *szSrc);
inline WORD Atos(const TCHAR *szSrc);
inline unsigned long Atoi(const TCHAR *szSrc);
inline DWORD64 Atol64(const TCHAR *szSrc);
// 값을 Hex String으로 바꿈
inline void Hex08ToStr(TCHAR *szDest, BYTE hex);
inline void Hex16ToStr(TCHAR *szDest, WORD hex);
inline void Hex32ToStr(TCHAR *szDest, unsigned long hex);
inline void Hex64ToStr(TCHAR *szDest, DWORD64 hex);
};
namespace Random
{
// 리턴값은 nBeginExtent ~ nEndExtent - 1의 범위를 갖는다.
unsigned long ComplexRandom(int nEndExtent, int nBeginExtent = 0); // 비교적 분포가 좋다.
int SimpleRandom(unsigned long dwSeed, int nEndExtent, int nBeginExtent = 0);
};
namespace HashFunc
{
// -------------------------------------------------------------------------------------------------
// String-to-Hash 함수들 : http://www.cs.yorku.ca/~oz/hash.html 에서 참고
inline unsigned long djb2Hash(const unsigned char *str); // first reported by dan bernstein
inline unsigned long sdbmHash(const unsigned char *str); // this is one of the algorithms used in berkeley db
inline unsigned long looseHash(const unsigned char *str); // 가장 간단한 해쉬. 그냥 모두 더함.
};
namespace Const
{
static float PI = 3.14159f;
}
};
#include "Convert.inl"
inline unsigned long Math::HashFunc::djb2Hash(const unsigned char *str)
{
unsigned long hash = 5381;
int c;
while (c = *str++) { hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ }
return hash;
}
inline unsigned long Math::HashFunc::sdbmHash(const unsigned char *str)
{
unsigned long hash = 0;
int c;
while (c = *str++) { hash = c + (hash << 6) + (hash << 16) - hash; }
return hash;
}
inline unsigned long Math::HashFunc::looseHash(const unsigned char *str)
{
unsigned int hash = 0;
int c;
while (c = *str++) { hash += c; }
return hash;
}
#endif // !defined(AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_)