xoreos
0.0.5
|
Utility templates and functions. More...
#include "src/common/util.h"
#include "src/common/debugman.h"
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
Go to the source code of this file.
Classes | |
union | floatConvert |
union | doubleConvert |
Functions | |
void | warning (const char *s,...) |
void | status (const char *s,...) |
void | info (const char *s,...) |
void NORETURN_PRE | error (const char *s,...) |
float | convertIEEEFloat (uint32 data) |
Convert a uint32 holding the bit pattern of a 32-bit IEEE 754 single precision floating point value into a real, native float. More... | |
uint32 | convertIEEEFloat (float value) |
Convert a native float into a uint32 holding the bit pattern a 32-bit IEEE 754 single precision floating point value. More... | |
double | convertIEEEDouble (uint64 data) |
Convert a uint64 holding the bit pattern of a 64-bit IEEE 754 double precision floating point value into a real, native double. More... | |
uint64 | convertIEEEDouble (double value) |
Convert a native double into a uint64 holding the bit pattern a 64-bit IEEE 754 double precision floating point value. More... | |
double | readNintendoFixedPoint (uint32 value, bool sign, uint8 iBits, uint8 fBits) |
Read a fixed-point value, in a format used by the Nintendo DS. More... | |
float | readIEEEFloat16 (uint16 value) |
Read a half-precision 16-bit IEEE float, converting it into a 32-bit iEEE float. More... | |
Utility templates and functions.
Definition in file util.cpp.
double convertIEEEDouble | ( | uint64 | data | ) |
Convert a uint64 holding the bit pattern of a 64-bit IEEE 754 double precision floating point value into a real, native double.
NOTE: Currently, this function assumes native doubles are 64-bit IEEE 754 double precision floating point values!
Definition at line 143 of file util.cpp.
References doubleConvert::dDouble, and doubleConvert::dInt.
Referenced by Common::FoxPro::getDouble(), Common::ReadStream::readIEEEDoubleBE(), Common::ReadStream::readIEEEDoubleLE(), Common::FoxPro::setDouble(), Common::WriteStream::writeIEEEDoubleBE(), and Common::WriteStream::writeIEEEDoubleLE().
uint64 convertIEEEDouble | ( | double | value | ) |
Convert a native double into a uint64 holding the bit pattern a 64-bit IEEE 754 double precision floating point value.
NOTE: Currently, this function assumes native doubles are 64-bit IEEE 754 double precision floating point values!
Definition at line 151 of file util.cpp.
References doubleConvert::dDouble, and doubleConvert::dInt.
float convertIEEEFloat | ( | uint32 | data | ) |
Convert a uint32 holding the bit pattern of a 32-bit IEEE 754 single precision floating point value into a real, native float.
NOTE: Currently, this function assumes native floats are 32-bit IEEE 754 single precision floating point values!
Definition at line 116 of file util.cpp.
References floatConvert::dFloat, and floatConvert::dInt.
Referenced by Common::FoxPro::getDouble(), Aurora::GFF3Struct::getDouble(), readIEEEFloat16(), Common::ReadStream::readIEEEFloatBE(), Common::ReadStream::readIEEEFloatLE(), Common::FoxPro::setDouble(), Common::WriteStream::writeIEEEFloatBE(), and Common::WriteStream::writeIEEEFloatLE().
uint32 convertIEEEFloat | ( | float | value | ) |
Convert a native float into a uint32 holding the bit pattern a 32-bit IEEE 754 single precision floating point value.
NOTE: Currently, this function assumes native floats are 32-bit IEEE 754 single precision floating point values!
Definition at line 125 of file util.cpp.
References floatConvert::dFloat, and floatConvert::dInt.
void NORETURN_PRE error | ( | const char * | s, |
... | |||
) |
Definition at line 86 of file util.cpp.
References DebugMan, and STRINGBUFLEN.
Referenced by Aurora::Lua::ScriptManager::atPanic(), Sound::SoundManager::bufferData(), Aurora::Lua::ScriptManager::callFunction(), Graphics::TTFRenderer::drawCharacter(), Sound::SoundManager::fillBuffer(), Graphics::Shader::ShaderManager::genGLProgram(), Graphics::Shader::ShaderManager::genGLShader(), Graphics::TTFRenderer::getCharWidth(), Video::QuickTimeDecoder::VideoTrackHandler::getNextFramePacket(), Sound::SoundManager::init(), Sound::SoundManager::isPlaying(), Aurora::Lua::Stack::isUserTypeAt(), main(), Sound::makeADPCMStream(), Engines::NWN::CharSpells::makeSpellsList(), Sound::MS_ADPCMStream::MS_ADPCMStream(), Sound::MSIma_ADPCMStream::MSIma_ADPCMStream(), Sound::SoundManager::pauseChannel(), Sound::SoundManager::playAudioStream(), Engines::NWN::ButtonsGroup::setActive(), Graphics::WindowManager::setGamma(), Engines::NWN::Creature::setRace(), Engines::NWN::CharFeats::setRecommendedFeats(), and Engines::ConsoleWindow::setRedirect().
void info | ( | const char * | s, |
... | |||
) |
Definition at line 69 of file util.cpp.
References DebugMan, and STRINGBUFLEN.
Referenced by Engines::KotOR::CharacterGenerationInfo::CharacterGenerationInfo(), Engines::KotOR::ClassSelectionMenu::createCharacterGeneration(), Engines::KotOR2::Creature::createPC(), Engines::KotOR::Creature::createPC(), Engines::KotOR2::CharacterGenerationInfo::createRandomFemaleConsular(), Engines::KotOR2::CharacterGenerationInfo::createRandomFemaleGuardian(), Engines::KotOR::CharacterGenerationInfo::createRandomFemaleScoundrel(), Engines::KotOR::CharacterGenerationInfo::createRandomFemaleScout(), Engines::KotOR2::CharacterGenerationInfo::createRandomFemaleSentinel(), Engines::KotOR::CharacterGenerationInfo::createRandomFemaleSoldier(), Engines::KotOR2::CharacterGenerationInfo::createRandomMaleConsular(), Engines::KotOR2::CharacterGenerationInfo::createRandomMaleGuardian(), Engines::KotOR::CharacterGenerationInfo::createRandomMaleScoundrel(), Engines::KotOR::CharacterGenerationInfo::createRandomMaleScout(), Engines::KotOR2::CharacterGenerationInfo::createRandomMaleSentinel(), Engines::KotOR::CharacterGenerationInfo::createRandomMaleSoldier(), Aurora::ActionScript::AVM::fsCommand(), Engines::KotOR::SavedGame::getPC(), Engines::GameInstanceEngine::listLanguages(), Engines::KotOR::CharacterGenerationInfo::operator=(), Graphics::Aurora::Model_Sonic::readBone(), Graphics::Aurora::Model_Sonic::readMaterialDefinition(), Graphics::Aurora::Model_Sonic::readPolygon(), Engines::KotOR2::CharacterGeneration::showName(), Engines::KotOR::CharacterGenerationMenu::showName(), Engines::KotOR2::CharacterGeneration::showPortrait(), and Engines::KotOR::CharacterGenerationMenu::showPortrait().
float readIEEEFloat16 | ( | uint16 | value | ) |
Read a half-precision 16-bit IEEE float, converting it into a 32-bit iEEE float.
Definition at line 198 of file util.cpp.
References convertIEEEFloat().
Referenced by Graphics::Aurora::ModelNode_DragonAge::read2Float32(), Graphics::Aurora::ModelNode_DragonAge::read3Float32(), and Graphics::Aurora::ModelNode_DragonAge::read4Float32().
Read a fixed-point value, in a format used by the Nintendo DS.
value | The integer representing the fixed-point value. |
sign | Is this a signed fixed-point value? |
iBits | Number of bits in the integer part. |
fBits | Number of bits in the fractional part. |
Definition at line 159 of file util.cpp.
References UINT64_C.
Referenced by Graphics::Aurora::Model_Sonic::createPrimitives(), Aurora::GFF4Struct::getDouble(), Aurora::GFF4Struct::getFloat(), Graphics::Aurora::Model_Sonic::readBone(), Aurora::GFXFile::readMatrix(), and Graphics::Aurora::Model_Sonic::readModel().
void status | ( | const char * | s, |
... | |||
) |
Definition at line 52 of file util.cpp.
References DebugMan, and STRINGBUFLEN.
Referenced by Engines::DragonAge::Functions::DEBUG_printToScreen(), Engines::DragonAge2::Functions::DEBUG_printToScreen(), Sound::Xbox_ADPCMStream::decodeXbox(), Graphics::Shader::ShaderManager::deinit(), Engines::KotOR::KotOREngine::detectVersion(), Engines::NWN::NWNEngine::detectVersion(), Engines::DragonAge2::Placeable::enter(), Engines::DragonAge::Placeable::enter(), Engines::DragonAge::Creature::enter(), Engines::DragonAge2::Creature::enter(), Engines::DragonAge::Campaign::enterArea(), Engines::DragonAge2::Campaign::enterArea(), Engines::Engine::evaluateLanguage(), Engines::fiddleLangChinese(), Engines::DragonAge::Campaigns::findCampaigns(), Engines::DragonAge2::Campaigns::findCampaigns(), Engines::NWN::Creature::getArmorModels(), Graphics::Shader::ShaderManager::getShaderObject(), Engines::GameThread::init(), Graphics::Mesh::MeshManager::init(), Graphics::Shader::MaterialManager::init(), Graphics::Shader::SurfaceManager::init(), Engines::KotOR2::KotOR2Engine::init(), Engines::Jade::JadeEngine::init(), init(), Engines::NWN2::NWN2Engine::init(), Engines::Sonic::SonicEngine::init(), Engines::KotOR::KotOREngine::init(), Engines::DragonAge::DragonAgeEngine::init(), Engines::DragonAge2::DragonAge2Engine::init(), Engines::Witcher::WitcherEngine::init(), Engines::NWN::NWNEngine::init(), Graphics::Shader::ShaderManager::init(), Engines::NWN::CharPremadeMenu::initCharacterList(), Engines::NWN::NewModuleMenu::initModuleList(), Engines::NWN::NewPremiumMenu::initModuleList(), Graphics::WindowManager::initRender(), Engines::DragonAge::Campaign::load(), Engines::DragonAge2::Campaign::load(), Engines::Witcher::Module::loadAreas(), Engines::NWN2::Module::loadAreas(), Engines::NWN::Module::loadAreas(), Engines::DragonAge::Room::loadLayout(), Engines::DragonAge2::Room::loadLayout(), Common::FoxPro::loadRecords(), Engines::KotOR::Module::loadTexturePack(), Engines::KotOR2::Module::loadTexturePack(), Engines::NWN::Module::loadTexturePack(), Engines::NWN::Area::loadTileset(), Common::DebugManager::logDebugGL(), Engines::DragonAge2::Functions::logTrace(), Engines::DragonAge::Functions::logTrace(), main(), Common::printException(), Engines::DragonAge2::Functions::printFloat(), Engines::DragonAge::Functions::printFloat(), Engines::NWN::Functions::printFloat(), Engines::NWN2::Functions::printFloat(), Engines::KotOR2::Functions::printFloat(), Engines::KotOR::Functions::printFloat(), Engines::Witcher::Functions::printFloat(), Engines::Jade::Functions::printFloat(), Engines::DragonAge2::Functions::printInteger(), Engines::DragonAge::Functions::printInteger(), Engines::NWN::Functions::printInteger(), Engines::NWN2::Functions::printInteger(), Engines::KotOR2::Functions::printInteger(), Engines::Witcher::Functions::printInteger(), Engines::KotOR::Functions::printInteger(), Engines::Jade::Functions::printInteger(), Engines::DragonAge::Functions::printObject(), Engines::DragonAge2::Functions::printObject(), Engines::KotOR2::Functions::printObject(), Engines::NWN::Functions::printObject(), Engines::NWN2::Functions::printObject(), Engines::Witcher::Functions::printObject(), Engines::KotOR::Functions::printObject(), Engines::Jade::Functions::printObject(), Engines::DragonAge::Functions::printResource(), Engines::DragonAge2::Functions::printResource(), Engines::DragonAge2::Functions::printString(), Engines::DragonAge::Functions::printString(), Engines::KotOR2::Functions::printString(), Engines::NWN2::Functions::printString(), Engines::NWN::Functions::printString(), Engines::KotOR::Functions::printString(), Engines::Witcher::Functions::printString(), Engines::Jade::Functions::printString(), Engines::DragonAge2::Functions::printToLog(), Engines::DragonAge::Functions::printToLog(), Engines::DragonAge2::Functions::printToLogAndFlush(), Engines::DragonAge::Functions::printToLogAndFlush(), Engines::DragonAge2::Functions::printToLogWindow(), Engines::DragonAge::Functions::printToLogWindow(), Engines::DragonAge::Functions::printVector(), Engines::DragonAge2::Functions::printVector(), Engines::NWN2::Functions::printVector(), Engines::KotOR2::Functions::printVector(), Engines::NWN::Functions::printVector(), Engines::Witcher::Functions::printVector(), Engines::KotOR::Functions::printVector(), Engines::Jade::Functions::printVector(), Engines::DragonAge::Functions::printWarning(), Engines::DragonAge2::Functions::printWarning(), Graphics::WindowManager::probeFSAA(), Engines::resolveLangInvalid(), Engines::resolveLangUnavailable(), Engines::Witcher::Object::speakString(), Engines::NWN2::Object::speakString(), Engines::Jade::Object::speakString(), Engines::NWN::Object::speakString(), Engines::LoadProgress::step(), Graphics::takeScreenshot(), Engines::NWN2::Functions::writeTimestampedLogEntry(), Engines::NWN::Functions::writeTimestampedLogEntry(), Engines::KotOR2::Functions::writeTimestampedLogEntry(), Engines::KotOR::Functions::writeTimestampedLogEntry(), Engines::Witcher::Functions::writeTimestampedLogEntry(), and Engines::Jade::Functions::writeTimestampedLogEntry().
void warning | ( | const char * | s, |
... | |||
) |
Definition at line 33 of file util.cpp.
References DebugMan, and STRINGBUFLEN.
Referenced by Engines::Jade::Functions::actionStartConversation(), Engines::NWN::Functions::actionStartConversation(), Aurora::ActionScript::ASBuffer::actionTrace(), Engines::NWN::Functions::beginConversation(), Engines::Jade::Module::changeModule(), Engines::checkConfigDouble(), Engines::checkConfigInt(), Graphics::Aurora::ModelNode_NWN_Binary::checkDuplicateNode(), Graphics::GraphicsManager::checkGLExtensions(), Aurora::ResourceManager::checkHashCollision(), Common::ConversionManager::ConversionManager(), Common::Thread::createThread(), Sound::WMACodec::decodeExpHuffman(), Video::XMVWMV2Codec::decodeJFrame(), Sound::MP3Stream::decodeMP3Data(), Sound::WMACodec::decodeNoise(), Sound::WMACodec::decodeRunLevel(), Sound::WMACodec::decodeSuperFrame(), Aurora::Lua::ScriptManager::deinit(), Common::Thread::destroyThread(), Graphics::DDS::detectFormat(), Engines::KotOR::KotOREngine::detectVersion(), Engines::NWN::NWNEngine::detectVersion(), Common::ConversionManager::doConvert(), Engines::Sonic::Placeable::enter(), Engines::Witcher::Module::enterArea(), Engines::NWN2::Module::enterArea(), Engines::NWN::Module::enterArea(), Sound::WMACodec::evalBlockLength(), Engines::Engine::evaluateLanguage(), Aurora::ActionScript::ASBuffer::execute(), Engines::KotOR::ActionExecutor::executeActions(), Sound::SoundManager::fillBuffer(), Engines::KotOR::SavedGame::fillFromModuleIFO(), Engines::KotOR::SavedGame::fillFromModuleSAV(), Engines::KotOR::SavedGame::fillFromSAV(), Graphics::Aurora::Model_Sonic::findStackBones(), Engines::NWN::ButtonsGroup::getChoice(), Common::FilePath::getFileSize(), Sound::FMODSampleBank::getSample(), Aurora::Lua::Stack::getTypeAt(), Engines::KotOR2::KotOR2Engine::init(), Engines::Jade::JadeEngine::init(), Engines::NWN2::NWN2Engine::init(), Engines::Sonic::SonicEngine::init(), Engines::KotOR::KotOREngine::init(), Engines::DragonAge2::DragonAge2Engine::init(), Engines::DragonAge::DragonAgeEngine::init(), Engines::NWN::NWNEngine::init(), Video::QuickTimeDecoder::VideoSampleDesc::initCodec(), Graphics::WindowManager::initRender(), Video::QuickTimeDecoder::AudioSampleDesc::isAudioCodecSupported(), Engines::NWN::Functions::jumpTo(), Engines::NWN2::Functions::jumpTo(), Engines::Witcher::Functions::jumpTo(), Engines::Jade::Functions::jumpTo(), Engines::KotOR::Walkmesh::load(), Engines::KotOR::Trigger::load(), Engines::KotOR2::Trigger::load(), Aurora::VISFile::load(), Graphics::Aurora::Model_Jade::load(), Graphics::Aurora::ModelNode_Witcher::load(), Engines::KotOR2::Placeable::load(), Graphics::Aurora::ModelNode_DragonAge::load(), Graphics::Aurora::ModelNode_Jade::load(), Engines::KotOR::Placeable::load(), Engines::KotOR::Door::load(), Engines::KotOR2::Door::load(), Engines::KotOR2::Situated::load(), Engines::KotOR::Situated::load(), Graphics::Aurora::ModelNode_NWN_ASCII::load(), Engines::KotOR2::Creature::load(), Sound::ASFStream::load(), Video::Bink::load(), Video::XboxMediaVideo::load(), Aurora::NWScript::NCSFile::load(), Engines::KotOR::Creature::load(), Aurora::GFXFile::load(), Engines::Jade::Placeable::loadAppearance(), Engines::KotOR2::Creature::loadAppearance(), Engines::KotOR::Creature::loadAppearance(), Graphics::Aurora::Model_NWN::loadASCII(), Engines::NWN::Situated::loadModel(), Engines::NWN2::Situated::loadModel(), Engines::Witcher::Situated::loadModel(), Engines::NWN2::Creature::loadModel(), Engines::NWN::Item::loadModel(), Engines::NWN::Creature::loadModel(), Engines::Jade::Placeable::loadProperties(), Graphics::Aurora::ModelNode_NWN2::loadRigid(), Graphics::Aurora::ModelNode_NWN2::loadSkin(), main(), Aurora::BZFFile::mergeKEY(), Aurora::BIFFile::mergeKEY(), Aurora::NWScript::NCSFile::o_storestateall(), Common::ReadFile::open(), Graphics::Aurora::Model_Sonic::parseBoneCommands(), parseCommandline(), Video::XMVWMV2Codec::parseExtraData(), Sound::PacketizedVorbisStream::parseExtraData(), parseOption(), Sound::SoundManager::pauseChannel(), Engines::Jade::Object::playAnimation(), Engines::NWN::Object::playAnimation(), Engines::NWN::Functions::playAnimation(), Engines::NWN::Creature::playAnimation(), Sound::SoundManager::playSoundFile(), Graphics::Aurora::ModelNode_NWN_ASCII::processMesh(), Video::XboxMediaVideo::processNextFrame(), Video::XboxMediaVideo::processPacketHeader(), Aurora::Lua::Stack::pushVariable(), Graphics::Aurora::Model_KotOR::readAnim(), Graphics::Aurora::Model::readArrayDef(), Sound::PacketizedVorbisStream::readBuffer(), Video::QuickTimeDecoder::readDefault(), Aurora::GFXFile::readDefineEditText(), Aurora::GFXFile::readDefineFont(), Aurora::GFXFile::readDefineSprite(), Video::QuickTimeDecoder::readELST(), Aurora::GFXFile::readFileAttributes(), Sound::MP3Stream::readHeader(), Aurora::GFXFile::readInitAction(), Graphics::Aurora::ModelNode_NWN_Binary::readMesh(), Graphics::Aurora::ModelNode_KotOR::readMesh(), Video::QuickTimeDecoder::readMVHD(), Graphics::Aurora::ModelNode_KotOR::readOrientationController(), Graphics::Aurora::ModelNode_KotOR::readPositionController(), Video::QuickTimeDecoder::readSampleDesc(), Engines::NWN2::Object::readVarTable(), Engines::NWN::Tooltip::redoBubble(), Sound::VorbisStream::refill(), Engines::resolveLangInvalid(), Engines::resolveLangUnavailable(), Engines::NWN::Functions::sendMessageToPC(), Engines::NWN2::Functions::sendMessageToPC(), Engines::KotOR2::Functions::sendMessageToPC(), Engines::Witcher::Functions::sendMessageToPC(), Engines::KotOR::Functions::sendMessageToPC(), Engines::Jade::Functions::sendMessageToPC(), Graphics::Aurora::TextureManager::set(), Engines::KotOR::HUD::setMinimap(), setOption(), Engines::KotOR::Minimap::setPosition(), Engines::NWN::CharGenChoices::setRace(), Engines::KotOR::HUD::setRotation(), Graphics::GraphicsManager::setupSDLGL(), Engines::KotOR::DialogGUIBase::startConversation(), Engines::Witcher::Functions::startNewModule(), Engines::NWN::Functions::startNewModule(), Engines::NWN2::Functions::startNewModule(), Graphics::takeScreenshot(), Engines::KotOR::SaveLoadMenu::tryLoadGame(), Graphics::Aurora::ModelNode_Jade::unfoldFaces(), Engines::Witcher::unimplementedFunction(), Engines::DragonAge2::Functions::unimplementedFunction(), Engines::DragonAge::Functions::unimplementedFunction(), Engines::Witcher::Functions::unimplementedFunction(), Engines::NWN::Functions::unimplementedFunction(), Engines::NWN2::Functions::unimplementedFunction(), Engines::KotOR2::Functions::unimplementedFunction(), Engines::KotOR::Functions::unimplementedFunction(), Engines::Jade::Functions::unimplementedFunction(), Engines::Witcher::unimplementedVariable(), and Sound::VorbisStream::VorbisStream().