ReGameDLL_CS/regamedll/public/commonmacros.h
2015-06-30 15:46:07 +06:00

31 lines
1.2 KiB
C

#ifndef COMMONMACROS_H
#define COMMONMACROS_H
#pragma once
// -------------------------------------------------------
//
// commonmacros.h
//
// This should contain ONLY general purpose macros that are
// appropriate for use in engine/launcher/all tools
//
// -------------------------------------------------------
#include "osconfig.h"
// Makes a 4-byte "packed ID" int out of 4 characters
#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) )
// Compares a string with a 4-byte packed ID constant
#define STRING_MATCHES_ID( p, id ) ( (*((int *)(p)) == (id) ) ? true : false )
#define ID_TO_STRING( id, p ) ( (p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF) )
#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
// Keeps clutter down a bit, when using a float as a bit-vector
#define SETBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
#define CLEARBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
#define FBitSet(flBitVector, bit) ((flBitVector) & (bit))
#endif // COMMONMACROS_H