Added reasons to assertions

This commit is contained in:
2023-07-23 10:15:37 -07:00
parent ef6b269141
commit 5b01eb904d
78 changed files with 357 additions and 289 deletions

View File

@ -8,8 +8,8 @@
using namespace Dawn;
Asset::Asset(AssetManager *assetManager, std::string name) {
assertTrue(name.size() > 0);
assertNotNull(assetManager);
assertTrue(name.size() > 0, "Asset::Asset: Name cannot be empty");
assertNotNull(assetManager, "Asset::Asset: AssetManager cannot be null");
this->assetManager = assetManager;
this->name = name;

View File

@ -8,58 +8,58 @@
using namespace Dawn;
AssetLoader::AssetLoader(std::string fileName) {
assertTrue(fileName.size() > 0);
assertTrue(fileName.size() > 0, "AssetLoader::AssetLoader: fileName must be greater than 0");
this->fileName = fileName;
this->handle = nullptr;
}
void AssetLoader::open() {
assertNull(this->handle);
assertNull(this->handle, "AssetLoader::open: File is already open");
std::string pathFull = DAWN_ASSET_BUILD_PREFIX + this->fileName;
this->handle = fopen(pathFull.c_str(), "rb");
assertNotNull(this->handle);
assertNotNull(this->handle, "AssetLoader::open: Failed to open file");
}
int32_t AssetLoader::close() {
assertNotNull(this->handle);
assertNotNull(this->handle, "AssetLoader::close: File is not open");
int32_t ret = fclose(this->handle);
this->handle = nullptr;
return ret;
}
size_t AssetLoader::read(uint8_t *buffer, size_t size) {
assertNotNull(buffer);
assertTrue(size > 0);
assertNotNull(this->handle);
assertNotNull(buffer, "AssetLoader::read: buffer must not be null");
assertTrue(size > 0, "AssetLoader::read: size must be greater than 0");
assertNotNull(this->handle, "AssetLoader::read: File is not open");
return fread(buffer, 1, size, this->handle);
}
int32_t AssetLoader::end() {
assertNotNull(this->handle);
assertNotNull(this->handle, "AssetLoader::end: File is not open");
return fseek(this->handle, 0, SEEK_END);
}
size_t AssetLoader::skip(size_t n) {
assertTrue(n > 0);
assertNotNull(this->handle);
assertTrue(n > 0, "AssetLoader::skip: n must be greater than 0");
assertNotNull(this->handle, "AssetLoader::skip: File is not open");
return fseek(this->handle, n, SEEK_CUR);
}
int32_t AssetLoader::rewind() {
assertNotNull(this->handle);
assertNotNull(this->handle, "AssetLoader::rewind: File is not open");
return fseek(this->handle, 0, SEEK_SET);
}
size_t AssetLoader::getPosition() {
assertNotNull(this->handle);
assertNotNull(this->handle, "AssetLoader::getPosition: File is not open");
return ftell(this->handle);
}
size_t AssetLoader::loadRaw(uint8_t **buffer) {
size_t length, read;
assertNotNull(buffer);
assertNotNull(buffer, "AssetLoader::loadRaw: buffer must not be null");
// Open a buffer.
this->open();
@ -92,7 +92,7 @@ size_t AssetLoader::loadRaw(uint8_t **buffer) {
}
size_t AssetLoader::setPosition(size_t position) {
assertTrue(position >= 0);
assertTrue(position >= 0, "AssetLoader::setPosition: position must be greater than or equal to 0");
this->rewind();
return this->skip(position);
}

View File

@ -79,7 +79,7 @@ namespace Dawn {
*/
template<class T>
T * get(std::string name) {
assertTrue(name.size() > 0);
assertTrue(name.size() > 0, "AssetManager::get: name must be greater than 0");
auto existing = this->assets.find(name);
if(existing != this->assets.end()) {
@ -105,11 +105,11 @@ namespace Dawn {
template<class T>
void unload(T *asset) {
assertUnreachable();
assertUnreachable("AssetManager::unload: NOT IMPLEMENTED");
}
void unload(std::string name) {
assertUnreachable();
assertUnreachable("AssetManager::unload: NOT IMPLEMENTED");
}
/**

View File

@ -41,7 +41,7 @@ void AudioAsset::updateAsync() {
end = strchr(start, '|');
*end = '\0';
this->channelCount = atoi(start);
assertTrue(this->channelCount > 0);
assertTrue(this->channelCount > 0, "AudioAsset::updateAsync: Channel count must be greater than 0");
// Sample Rate
this->state = 0x04;
@ -49,7 +49,7 @@ void AudioAsset::updateAsync() {
end = strchr(start, '|');
*end = '\0';
this->sampleRate = (uint32_t)strtoul(start, NULL, 10);
assertTrue(this->sampleRate > 0);
assertTrue(this->sampleRate > 0, "AudioAsset::updateAsync: Sample rate must be greater than 0");
// Number of samples per channel
this->state = 0x05;
@ -57,7 +57,7 @@ void AudioAsset::updateAsync() {
end = strchr(start, '|');
*end = '\0';
this->samplesPerChannel = atoi(start);
assertTrue(this->samplesPerChannel > 0);
assertTrue(this->samplesPerChannel > 0, "AudioAsset::updateAsync: Samples per channel must be greater than 0");
// Total Data Length
this->state = 0x06;
@ -65,7 +65,7 @@ void AudioAsset::updateAsync() {
end = strchr(start, '|');
*end = '\0';
this->bufferSize = (size_t)atoll(start);
assertTrue(this->bufferSize > 0);
assertTrue(this->bufferSize > 0, "AudioAsset::updateAsync: Buffer size must be greater than 0");
// Determine frame size
this->frameSize = sizeof(int16_t) * this->channelCount;

View File

@ -19,7 +19,7 @@ void LanguageAsset::updateSync() {
}
void LanguageAsset::updateAsync() {
assertTrue(this->state == 0x00);
assertTrue(this->state == 0x00, "LanguageAsset::updateAsync: State must be 0x00");
// Open Asset
this->state = 0x01;
@ -71,9 +71,9 @@ void LanguageAsset::updateAsync() {
}
std::string LanguageAsset::getValue(std::string key) {
assertTrue(this->state == 0x07);
assertMapHasKey(this->values, key);
assertTrue(this->values[key].begin >= 0 && this->values[key].length > 0);
assertTrue(this->state == 0x07, "LanguageAsset::getValue: State must be 0x07");
assertMapHasKey(this->values, key, "LanguageAsset::getValue: Key does not exist");
assertTrue(this->values[key].begin >= 0 && this->values[key].length > 0, "LanguageAsset::getValue: Value is invalid");
// Get the positions
struct AssetLanguageValue value = this->values[key];

View File

@ -58,7 +58,7 @@ void TextureAsset::updateAsync() {
switch(parseState) {
case TEXTURE_ASSET_HEADER_PARSE_STATE_VERSION: {
auto compared = strcmp(integer, "DT_2.00");
assertTrue(compared == 0);
assertTrue(compared == 0, "TextureAsset::updateAsync: Invalid version");
j = 0;
parseState = TEXTURE_ASSET_HEADER_PARSE_STATE_WIDTH;
break;
@ -66,7 +66,7 @@ void TextureAsset::updateAsync() {
case TEXTURE_ASSET_HEADER_PARSE_STATE_WIDTH: {
this->width = atoi(integer);
assertTrue(this->width > 0);
assertTrue(this->width > 0, "TextureAsset::updateAsync: Invalid width");
j = 0;
parseState = TEXTURE_ASSET_HEADER_PARSE_STATE_HEIGHT;
break;
@ -74,7 +74,7 @@ void TextureAsset::updateAsync() {
case TEXTURE_ASSET_HEADER_PARSE_STATE_HEIGHT: {
this->height = atoi(integer);
assertTrue(this->height > 0);
assertTrue(this->height > 0, "TextureAsset::updateAsync: Invalid height");
j = 0;
parseState = TEXTURE_ASSET_HEADER_PARSE_STATE_FORMAT;
break;
@ -116,7 +116,7 @@ void TextureAsset::updateAsync() {
}
default:
assertUnreachable();
assertUnreachable("TextureAsset::updateAsync: Invalid parse state");
}
}

View File

@ -20,7 +20,7 @@ void TilesetAsset::updateSync() {
void TilesetAsset::updateAsync() {
uint8_t *buffer;
assertTrue(this->state == 0x00);
assertTrue(this->state == 0x00, "TilesetAsset::updateAsync: Initial state should be 0x00");
this->state = 0x01;
this->loader.loadRaw(&buffer);
@ -34,28 +34,28 @@ void TilesetAsset::updateAsync() {
*strNext = '\0';
this->tileset.columns = atoi(strCurrent);
this->state = 0x03;
assertTrue(this->tileset.columns > 0);
assertTrue(this->tileset.columns > 0, "TilesetAsset::updateAsync: Count of columns needs to be greater than 0");
strCurrent = strNext+1;
strNext = strchr(strCurrent, '|');
*strNext = '\0';
this->tileset.rows = atoi(strCurrent);
this->state = 0x04;
assertTrue(this->tileset.rows > 0);
assertTrue(this->tileset.rows > 0, "TilesetAsset::updateAsync: Count of rows needs to be greater than 0");
strCurrent = strNext+1;
strNext = strchr(strCurrent, '|');
*strNext = '\0';
this->tileset.divX = atoi(strCurrent);
this->state = 0x05;
assertTrue(this->tileset.rows > 0);
assertTrue(this->tileset.divX > 0, "TilesetAsset::updateAsync: divX needs to be greater than 0");
strCurrent = strNext+1;
strNext = strchr(strCurrent, '|');
*strNext = '\0';
this->tileset.divY = atoi(strCurrent);
this->state = 0x06;
assertTrue(this->tileset.rows > 0);
assertTrue(this->tileset.divY > 0, "TilesetAsset::updateAsync: divY needs to be greater than 0");
// Begin reading tiles.
int32_t done = 0;

View File

@ -15,20 +15,20 @@ TrueTypeAsset::TrueTypeAsset(AssetManager *assMan, std::string name) :
this->locks.onLockRemoved = [&](usagelockid_t id){
auto texture = this->textureByLock[id];
assertNotNull(texture);
assertNotNull(texture, "TrueTypeAsset::TrueTypeAsset: Texture cannot be null");
std::vector<usagelockid_t> &lbt = this->locksByTexture[texture];
auto it0 = std::find(lbt.begin(), lbt.end(), id);
assertTrue(it0 != lbt.end());
assertTrue(it0 != lbt.end(), "TrueTypeAsset::TrueTypeAsset: Could not remove locksByTexture[texture]");
lbt.erase(it0);
auto it1 = this->textureByLock.find(id);
assertTrue(it1 != this->textureByLock.end());
assertTrue(it1 != this->textureByLock.end(), "TrueTypeAsset::TrueTypeAsset: Could not remove textureByLock");
this->textureByLock.erase(it1);
if(lbt.empty()) {
if(lbt.empty()) {
auto it2 = locksByTexture.find(texture);
assertTrue(it2 != locksByTexture.end());
assertTrue(it2 != locksByTexture.end(), "TrueTypeAsset::TrueTypeAsset: Could not remove locksByTexture");
locksByTexture.erase(it2);
auto it3 = textureByStyle.begin();
@ -38,7 +38,7 @@ TrueTypeAsset::TrueTypeAsset(AssetManager *assMan, std::string name) :
}
auto it4 = std::find(textures.begin(), textures.end(), texture);
assertTrue(it4 != textures.end());
assertTrue(it4 != textures.end(), "TrueTypeAsset::TrueTypeAsset: Could not remove textureByStyle");
textures.erase(it4);
delete texture;
@ -61,40 +61,40 @@ void TrueTypeAsset::updateAsync() {
uint8_t buffer[64];
this->loader.rewind();
size_t read = this->loader.read(buffer, sizeof(char) * 6);
assertTrue(read == (6 * sizeof(char)));
assertTrue(read == (6 * sizeof(char)), "TrueTypeAsset::updateAsync: Could not read header");
buffer[6] = '\0';
// Confirm "DE_TTF"
assertTrue(std::string((char *)buffer) == "DE_TTF");
assertTrue(std::string((char *)buffer) == "DE_TTF", "TrueTypeAsset::updateAsync: Header is invalid (Missing DE_TTF)");
// Vertical bar
this->loader.read(buffer, 1);
assertTrue(buffer[0] == '|');
assertTrue(buffer[0] == '|', "TrueTypeAsset::updateAsync: Header is invalid (Missing first vertical bar)");
// Read version
this->state = TRUE_TYPE_ASSET_STATE_VALIDATE_VERSION;
read = this->loader.read(buffer, sizeof(char) * 5);
assertTrue(buffer[0] == '3');
assertTrue(buffer[1] == '.');
assertTrue(buffer[2] == '0');
assertTrue(buffer[3] == '0');
assertTrue(buffer[4] == '|');
assertTrue(buffer[0] == '3', "TrueTypeAsset::updateAsync: Version is invalid 3");
assertTrue(buffer[1] == '.', "TrueTypeAsset::updateAsync: Version is invalid .");
assertTrue(buffer[2] == '0', "TrueTypeAsset::updateAsync: Version is invalid 0(1)");
assertTrue(buffer[3] == '0', "TrueTypeAsset::updateAsync: Version is invalid 0(2)");
assertTrue(buffer[4] == '|', "TrueTypeAsset::updateAsync: Version is invalid (Missing second vertical bar)");
// Read the count of font styles / variants.
size_t styleListBegin = this->loader.getPosition();
this->state = TRUE_TYPE_ASSET_STATE_READ_VARIANT_COUNT;
read = this->loader.read(buffer, 64);
assertTrue(read > 0);
assertTrue(read > 0, "TrueTypeAsset::updateAsync: Could not read variant count");
// Get position of vertical bar.
size_t i = 0;
while(buffer[i] != '|' && i < 64) i++;
assertTrue(buffer[i] == '|');
assertTrue(buffer[i] == '|', "TrueTypeAsset::updateAsync: Could not find vertical bar");
styleListBegin += i + 1;
buffer[i] = '\0';
int32_t count = atoi((char *)buffer);
assertTrue(count > 0);
assertTrue(count > 0, "TrueTypeAsset::updateAsync: Invalid variant count");
// Now begin parsing each font style.
this->state = TRUE_TYPE_ASSET_STATE_READ_VARIANT;
@ -106,7 +106,7 @@ void TrueTypeAsset::updateAsync() {
this->loader.rewind();
this->loader.setPosition(styleListBegin);
read = this->loader.read(buffer, 32);
assertTrue(read == 32);
assertTrue(read == 32, "TrueTypeAsset::updateAsync: Could not read variant");
// Read style
i = 0;
@ -119,7 +119,7 @@ void TrueTypeAsset::updateAsync() {
this->loader.rewind();
this->loader.setPosition(styleListBegin);
read = this->loader.read(buffer, 32);
assertTrue(read == 32);
assertTrue(read == 32, "TrueTypeAsset::updateAsync: Could not read variant style");
// Read length
i = 0;
@ -145,7 +145,7 @@ void TrueTypeAsset::updateAsync() {
// Init FreeType
this->state = TRUE_TYPE_ASSET_STATE_INIT_FREETYPE;
int32_t ret = FT_Init_FreeType(&fontLibrary);
assertTrue(ret == 0);
assertTrue(ret == 0, "TrueTypeAsset::updateAsync: Could not init FreeType");
// Done parsing!
this->state = TRUE_TYPE_ASSET_STATE_READY;
@ -153,7 +153,7 @@ void TrueTypeAsset::updateAsync() {
}
usagelockid_t TrueTypeAsset::lock(struct TrueTypeFaceTextureStyle style) {
assertTrue(this->state == TRUE_TYPE_ASSET_STATE_READY);
assertTrue(this->state == TRUE_TYPE_ASSET_STATE_READY, "TrueTypeAsset::lock: Asset is not ready");
// Try and find an existing texture that matches this style
auto it = this->textureByStyle.find(style);
@ -169,19 +169,19 @@ usagelockid_t TrueTypeAsset::lock(struct TrueTypeFaceTextureStyle style) {
}
++itAssetStyle;
}
assertTrue(itAssetStyle != this->assetStyles.end());
assertTrue(itAssetStyle != this->assetStyles.end(), "TrueTypeAsset::lock: Could not find asset style");
// Create and read buffer.
uint8_t *dataBuffer = (uint8_t*)memoryAllocate(sizeof(uint8_t) * itAssetStyle->dataSize);
this->loader.rewind();
this->loader.setPosition(itAssetStyle->dataOffset);
auto read = this->loader.read(dataBuffer, itAssetStyle->dataSize);
assertTrue(read == itAssetStyle->dataSize);
assertTrue(read == itAssetStyle->dataSize, "TrueTypeAsset::lock: Could not read data");
// Create the face
FT_Face face;
auto ret = FT_New_Memory_Face(this->fontLibrary, (FT_Byte*)dataBuffer, itAssetStyle->dataSize, 0, &face);
assertTrue(ret == 0);
assertTrue(ret == 0, "TrueTypeAsset::lock: Could not create face");
texture = new TrueTypeFaceTexture(face, style);
memoryFree(dataBuffer);
@ -200,7 +200,7 @@ usagelockid_t TrueTypeAsset::lock(struct TrueTypeFaceTextureStyle style) {
TrueTypeFaceTexture * TrueTypeAsset::getTexture(usagelockid_t id) {
auto it = this->textureByLock.find(id);
assertTrue(it != this->textureByLock.end());
assertTrue(it != this->textureByLock.end(), "TrueTypeAsset::getTexture: Could not find texture");
return it->second;
}

View File

@ -14,7 +14,7 @@
using namespace Dawn;
RenderPipeline::RenderPipeline(RenderManager *renderManager) {
assertNotNull(renderManager);
assertNotNull(renderManager, "RenderPipeline::RenderPipeline: RenderManager cannot be null");
this->renderManager = renderManager;
}
@ -29,7 +29,7 @@ void RenderPipeline::render() {
}
void RenderPipeline::renderScene(Scene *scene) {
assertNotNull(scene);
assertNotNull(scene, "RenderPipeline::renderScene: Scene cannot be null");
// Render subscenes first.
auto subSceneControllers = scene->findComponents<SubSceneController>();
@ -82,8 +82,8 @@ void RenderPipeline::renderScene(Scene *scene) {
void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
std::vector<struct ShaderPassItem>::iterator itPassItem;
assertNotNull(scene);
assertNotNull(camera);
assertNotNull(scene, "RenderPipeline::renderSceneCamera: Scene cannot be null");
assertNotNull(camera, "RenderPipeline::renderSceneCamera: Camera cannot be null");
// Create a new render ID. Long story short this is a really dirty way of
// not sending parameters to shaders more than we need.
@ -91,7 +91,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
// Get the render target.
auto renderTarget = camera->getRenderTarget();
assertNotNull(renderTarget);
assertNotNull(renderTarget, "RenderPipeline::renderSceneCamera: Camera must have a render target");
// Update shader parameter buffers with current knowledge
struct RenderPipelineShaderBufferData shaderBufferData;
@ -183,7 +183,7 @@ void RenderPipeline::renderSceneCamera(Scene *scene, Camera *camera) {
auto itTextureSlot = item.textureSlots.begin();
while(itTextureSlot != item.textureSlots.end()) {
// Assert texture isn't null, just don't include it.
assertNotNull(itTextureSlot->second);
assertNotNull(itTextureSlot->second, "RenderPipeline::renderSceneCamera: Texture cannot be null (omit texture instead)");
if(boundTextures[itTextureSlot->first] != itTextureSlot->second) {
itTextureSlot->second->bind(itTextureSlot->first);

View File

@ -8,8 +8,8 @@
using namespace Dawn;
struct Tile Tileset::getTile(int32_t tile) {
assertTrue(tile >= 0);
assertTrue(tile < this->tiles.size());
assertTrue(tile >= 0, "Tileset::getTile: Tile must be greater than or equal to 0");
assertTrue(tile < this->tiles.size(), "Tileset::getTile: Tile is out of bounds");
return this->tiles[tile];
}
@ -55,16 +55,16 @@ TilesetGrid::TilesetGrid(
int32_t borderX,
int32_t borderY
) {
assertTrue(columns >= 1);
assertTrue(rows >= 1);
assertTrue(w >= 1);
assertTrue(h >= 1);
assertTrue(gapX >= 0);
assertTrue(gapY >= 0);
assertTrue(borderX >= 0);
assertTrue(borderY >= 0);
assertTrue(w >= (columns + (gapX * columns) + borderX + borderX));
assertTrue(h >= (rows + (gapY * rows) + borderY + borderY));
assertTrue(columns >= 1, "TilesetGrid::TilesetGrid: Columns must be greater than or equal to 1");
assertTrue(rows >= 1, "TilesetGrid::TilesetGrid: Rows must be greater than or equal to 1");
assertTrue(w >= 1, "TilesetGrid::TilesetGrid: Width must be greater than or equal to 1");
assertTrue(h >= 1, "TilesetGrid::TilesetGrid: Height must be greater than or equal to 1");
assertTrue(gapX >= 0, "TilesetGrid::TilesetGrid: GapX must be greater than or equal to 0");
assertTrue(gapY >= 0, "TilesetGrid::TilesetGrid: GapY must be greater than or equal to 0");
assertTrue(borderX >= 0, "TilesetGrid::TilesetGrid: BorderX must be greater than or equal to 0");
assertTrue(borderY >= 0, "TilesetGrid::TilesetGrid: BorderY must be greater than or equal to 0");
assertTrue(w >= (columns + (gapX * columns) + borderX + borderX), "TilesetGrid::TilesetGrid: Width is too small");
assertTrue(h >= (rows + (gapY * rows) + borderY + borderY), "TilesetGrid::TilesetGrid: Height is too small");
this->rows = rows;
this->columns = columns;
@ -99,7 +99,7 @@ float_t TilesetGrid::getTileHeight(int32_t tile) {
}
struct Tile TilesetGrid::getTileFromGrid(int32_t column, int32_t row) {
assertTrue(row > 0 && row < this->rows);
assertTrue(column > 0 && column < this->columns);
assertTrue(row > 0 && row < this->rows, "TilesetGrid::getTileFromGrid: Row is out of bounds");
assertTrue(column > 0 && column < this->columns, "TilesetGrid::getTileFromGrid: Column is out of bounds");
return this->getTile(row + (column * this->rows));
}

View File

@ -13,7 +13,7 @@ Transform::Transform(SceneItem *item) :
transformLocal(1.0f),
transformWorld(1.0f)
{
assertNotNull(item);
assertNotNull(item, "Transform::Transform: Item cannot be null");
this->item = item;
this->updateLocalValuesFromLocalTransform();
@ -147,7 +147,7 @@ void Transform::setWorldTransform(glm::mat4 transform) {
void Transform::setParent(Transform *parent) {
assertTrue(parent == nullptr || parent != this);
assertTrue(parent == nullptr || parent != this, "Transform::setParent: Cannot set parent to self");
auto currentParent = this->getParent();
if(currentParent == parent) return;

View File

@ -29,7 +29,7 @@ namespace Dawn {
* @param game Game that this render manager belongs to.
*/
IRenderManager(DawnGame *game) {
assertNotNull(game);
assertNotNull(game, "IRenderManager::IRenderManager: Game cannot be null");
this->game = game;
}

View File

@ -48,7 +48,7 @@ namespace Dawn {
* @param modifies Pointer to the value that will be modified.
*/
SimpleAnimation(T *modifies) {
assertNotNull(modifies);
assertNotNull(modifies, "SimpleAnimation::SimpleAnimation: Modifies cannot be null");
this->modifies = modifies;
}
@ -59,7 +59,7 @@ namespace Dawn {
* @param value Value at this given time.
*/
void addKeyframe(float_t time, T value) {
assertTrue(time >= 0);
assertTrue(time >= 0, "SimpleAnimation::addKeyframe: Time must be >= 0");
struct SimpleKeyframe<T> keyframe;
keyframe.time = time;

View File

@ -11,14 +11,14 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
FT_Face face,
struct TrueTypeFaceTextureStyle style
) {
assertTrue(style.fontSize < 256);
assertTrue(style.fontSize < 256, "TrueTypeFaceTexture::TrueTypeFaceTexture: Font size cannot be greater than 256");
this->face = face;
this->style = style;
// Set freetype font size prior to baking.
if(FT_Set_Pixel_Sizes(face, 0, style.fontSize)) {
assertUnreachable();
assertUnreachable("TrueTypeFaceTexture::TrueTypeFaceTexture: Failed to set font size");
}
size_t w = 0, h = 0;
@ -29,7 +29,7 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
// Load the character
auto ret = FT_Load_Char(face, c, FT_LOAD_BITMAP_METRICS_ONLY);
if(ret) {
assertUnreachable();
assertUnreachable("TrueTypeFaceTexture::TrueTypeFaceTexture: Failed to load character (0)");
}
if(face->glyph->bitmap.width == 0 || face->glyph->bitmap.rows == 0) continue;
@ -39,8 +39,8 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
h += face->glyph->bitmap.rows;
}
assertTrue(w > 0);
assertTrue(h > 0);
assertTrue(w > 0, "TrueTypeFaceTexture::TrueTypeFaceTexture: Width cannot be less than or equal to 0");
assertTrue(h > 0, "TrueTypeFaceTexture::TrueTypeFaceTexture: Height cannot be less than or equal to 0");
// Now buffer pixels to the texture
float_t y = 0;
@ -54,7 +54,7 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
for(c = TRUE_TYPE_CHAR_BEGIN; c < TRUE_TYPE_CHAR_END; c++) {
// Load the character
if(FT_Load_Char(face, c, FT_LOAD_RENDER)) {
assertUnreachable();
assertUnreachable("TrueTypeFaceTexture::TrueTypeFaceTexture: Failed to load character (1)");
}
// Store the character information
@ -74,7 +74,7 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
face->glyph->bitmap.width * sizeof(uint8_t)
);
offset += w * sizeof(uint8_t);
assertTrue(offset <= (w * h * sizeof(uint8_t)));
assertTrue(offset <= (w * h * sizeof(uint8_t)), "TrueTypeFaceTexture::TrueTypeFaceTexture: Buffer overflow");
}
y += face->glyph->bitmap.rows;
}

View File

@ -16,7 +16,7 @@ void CapsuleMesh::calculateRing(
float_t dy,
std::vector<glm::vec3> *positions
) {
assertNotNull(positions);
assertNotNull(positions, "CapsuleMesh::calculateRing: positions cannot be null");
float_t segIncr = 1.0f / (float_t)(segments - 1);
for(int32_t s = 0; s < segments; s++ ) {
float_t x = cosf(MATH_PI * 2 * s * segIncr) * dr;
@ -30,7 +30,7 @@ void CapsuleMesh::create(
float_t radius,
float_t height
) {
assertNotNull(mesh);
assertNotNull(mesh, "CapsuleMesh::create: Mesh cannot be null");
std::vector<glm::vec3> positions;
std::vector<meshindice_t> indices;

View File

@ -12,7 +12,7 @@ void CubeMesh::buffer(
glm::vec3 pos, glm::vec3 size,
int32_t verticeStart, int32_t indiceStart
) {
assertNotNull(mesh);
assertNotNull(mesh, "CubeMesh::buffer: Mesh cannot be null");
glm::vec3 positions[CUBE_VERTICE_COUNT] = {
pos,

View File

@ -13,7 +13,7 @@ void QuadMesh::bufferQuadMeshWithZ(
glm::vec2 xy1, glm::vec2 uv1,
float_t z, int32_t verticeStart, int32_t indiceStart
) {
assertNotNull(mesh);
assertNotNull(mesh, "QuadMesh::bufferQuadMeshWithZ: Mesh cannot be null");
glm::vec3 positions[QUAD_VERTICE_COUNT] = {
glm::vec3(xy0, z),
@ -51,7 +51,7 @@ void QuadMesh::bufferCoordinates(
glm::vec2 uv0, glm::vec2 uv1,
int32_t verticeStart
) {
assertNotNull(mesh);
assertNotNull(mesh, "QuadMesh::bufferCoordinates: Mesh cannot be null");
glm::vec2 coordinates[QUAD_VERTICE_COUNT] = {
uv0, glm::vec2(uv1.x, uv0.y),
glm::vec2(uv0.x, uv1.y), uv1
@ -64,7 +64,7 @@ void QuadMesh::bufferPositions(
glm::vec2 xy0, glm::vec2 xy1,
int32_t verticeStart
) {
assertNotNull(mesh);
assertNotNull(mesh, "QuadMesh::bufferPositions: Mesh cannot be null");
glm::vec3 positions[QUAD_VERTICE_COUNT] = {
glm::vec3(xy0, 0),
glm::vec3(xy1.x, xy0.y, 0),
@ -80,7 +80,7 @@ void QuadMesh::initQuadMesh(
glm::vec2 xy1, glm::vec2 uv1,
float_t z
) {
assertNotNull(mesh);
assertNotNull(mesh, "QuadMesh::initQuadMesh: Mesh cannot be null");
mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
QuadMesh::bufferQuadMeshWithZ(mesh, xy0, uv0, xy1, uv1, z, 0, 0);
}

View File

@ -8,7 +8,7 @@
using namespace Dawn;
void TriangleMesh::createTriangleMesh(Mesh *mesh) {
assertNotNull(mesh);
assertNotNull(mesh, "TriangleMesh::createTriangleMesh: Mesh cannot be null");
glm::vec3 positions[3] = {
glm::vec3(-0.5f, -0.5f, 0),

View File

@ -32,7 +32,7 @@ namespace Dawn {
* @param callback Callback method that invokes back.
*/
EventListener(T *instance, void (T::*callback)(A... args)) {
assertNotNull(instance);
assertNotNull(instance, "EventListener::EventListener: Instance cannot be null");
this->instance = instance;
this->callback = callback;
@ -64,10 +64,10 @@ namespace Dawn {
T *instance,
void (T::*callback)(A... args)
) {
assertNotNull(instance);
assertNotNull(instance, "Event::addListener: Instance cannot be null");
auto listener = new EventListener<T,A...>(instance, callback);
assertNotNull(listener);
assertNotNull(listener, "Event::addListener: Listener could not be created (Memory filled?)");
this->listeners.push_back(listener);
return listener;
}

View File

@ -12,7 +12,7 @@ enum TicTacToeTileState Dawn::ticTacToeDetermineWinner(
std::vector<uint8_t> *winningCombo
) {
uint8_t i;
assertNotNull(winningCombo);
assertNotNull(winningCombo, "ticTacToeDetermineWinner: winningCombo cannot be null");
// Check rows
for(i = 0; i < 9; i += 3) {

View File

@ -16,7 +16,7 @@ VNTextboxScroller::VNTextboxScroller(SceneItem *item) :
}
void VNTextboxScroller::onStart() {
assertNotNull(label);
assertNotNull(label, "VNTextboxScroller::onStart: Label cannot be null");
std::function<void()> x = [&]{
this->lineCurrent = 0;
@ -101,5 +101,4 @@ bool_t VNTextboxScroller::hasRevealedAllCharacters() {
this->lineCurrent + this->visibleLines >=
this->label->lines.size()
);
assertUnreachable();
}

View File

@ -29,8 +29,8 @@ VNEvent * VNEvent::getNextEvent() {
}
void VNEvent::next() {
assertNotNull(this->manager);
assertNotNull(this->parent);
assertNotNull(this->manager, "VNEvent::next: Manager cannot be null");
assertNotNull(this->parent, "VNEvent::next: Parent cannot be null");
this->end();
auto next = this->getNextEvent();

View File

@ -19,8 +19,8 @@ namespace Dawn {
protected:
void onStart() override {
assertNotNull(ifTrue);
assertNotNull(ifEnd);
assertNotNull(ifTrue, "VNIfEvent::onStart: ifTrue cannot be null");
assertNotNull(ifEnd, "VNIfEvent::onStart: ifEnd cannot be null");
if(this->manager->getFlag(key) == value) {
useEvent([&]{

View File

@ -18,7 +18,7 @@ namespace Dawn {
void onStart() override {
scroller = this->getScene()->findComponent<VNTextboxScroller>();
assertNotNull(scroller);
assertNotNull(scroller, "VNTextEvent::onStart: VNTextboxScroller cannot be null");
auto richText = stringReplaceAll(this->manager->defaultFont, "{{ text }}", this->text);
scroller->label->richText = richText;

View File

@ -37,7 +37,7 @@ namespace Dawn {
StateEvent<inputbind_t> eventBindReleased;
IInputManager(DawnGame *game) {
assertNotNull(game);
assertNotNull(game, "IInputManager::IInputManager: Game cannot be null");
this->game = game;
}

View File

@ -57,7 +57,7 @@ struct Locale LocaleManager::getLocale() {
}
std::string LocaleManager::getString(std::string key) {
assertNotNull(this->currentlyLoadedAsset);
assertNotNull(this->currentlyLoadedAsset, "LocaleManager::getString: Currently loaded asset cannot be null");
return this->currentlyLoadedAsset->getValue(key);
}

View File

@ -39,9 +39,9 @@ bool_t Dawn::raytestTriangle(
glm::vec3 *hitNormal,
float_t *hitDistance
) {
assertNotNull(hitPoint);
assertNotNull(hitNormal);
assertNotNull(hitDistance);
assertNotNull(hitPoint, "Ray3D::raytestTriangle: hitPoint cannot be null");
assertNotNull(hitNormal, "Ray3D::raytestTriangle: hitNormal cannot be null");
assertNotNull(hitDistance, "Ray3D::raytestTriangle: hitDistance cannot be null");
// Calculate the normal of the triangle
glm::vec3 e0 = triangle.v1 - triangle.v0;
@ -92,9 +92,9 @@ bool_t Dawn::raytestAABB(
glm::vec3 *normal,
float_t *distance
) {
assertNotNull(point);
assertNotNull(normal);
assertNotNull(distance);
assertNotNull(point, "Ray3D::raytestAABB: point cannot be null");
assertNotNull(normal, "Ray3D::raytestAABB: normal cannot be null");
assertNotNull(distance, "Ray3D::raytestAABB: distance cannot be null");
// Compute the inverse direction of the ray, for numerical stability
glm::vec3 invDir(1.0f / ray.direction.x, 1.0f / ray.direction.y, 1.0f / ray.direction.z);
@ -176,9 +176,9 @@ bool_t Dawn::raytestQuad(
glm::vec3 *normal,
float_t *distance
) {
assertNotNull(point);
assertNotNull(normal);
assertNotNull(distance);
assertNotNull(point, "Ray3D::raytestQuad: point cannot be null");
assertNotNull(normal, "Ray3D::raytestQuad: normal cannot be null");
assertNotNull(distance, "Ray3D::raytestQuad: distance cannot be null");
// transform ray into local space of the quad
glm::mat4 inverseTransform = glm::inverse(transform);

View File

@ -29,7 +29,7 @@ namespace Dawn {
* @return The instance of the created prefab.
*/
static O * create(J *context) {
assertNotNull(context);
assertNotNull(context, "Prefab::create: Context cannot be null");
return P::prefabCreate(context);
}
};

View File

@ -14,7 +14,7 @@ bool_t SaveFile::has(std::string key) {
savedata_t SaveFile::get(std::string key) {
auto exist = this->values.find(key);
assertTrue(exist != this->values.end());
assertTrue(exist != this->values.end(), "SaveFile::get: Key does not exist");
return exist->second;
}

View File

@ -15,7 +15,7 @@ SaveManager::SaveManager(DawnGame *game) {
void SaveManager::saveFile() {
savedata_t value;
assertTrue(this->currentSaveSlot >= 0);
assertTrue(this->currentSaveSlot >= 0, "SaveManager::saveFile: Current save slot must be greater than or equal to 0");
// Update metadata
auto timestamp = this->game->timeManager.getTimestamp();
@ -30,7 +30,7 @@ void SaveManager::saveFile() {
FILE *fptr = fopen(filename, "wb");
if(fptr == NULL) {
printf("Error opening %s\n", filename);
assertUnreachable();
assertUnreachable("SaveManager::saveFile: Error opening file");
return;
}
@ -60,7 +60,7 @@ void SaveManager::saveFile() {
enum SaveLoadResult SaveManager::loadFile() {
this->currentSave.reset();
assertTrue(this->currentSaveSlot >= 0);
assertTrue(this->currentSaveSlot >= 0, "SaveManager::loadFile: Current save slot must be greater than or equal to 0");
// Load file
struct SaveFile temporaryFile;
@ -201,11 +201,11 @@ enum SaveLoadResult SaveManager::loadFile() {
}
void SaveManager::deleteFile(int16_t slot) {
assertTrue(slot >= 0);
assertTrue(slot >= 0, "SaveManager::deleteFile: Slot must be greater than or equal to 0");
}
void SaveManager::useSlot(int16_t slot) {
assertTrue(slot >= 0);
assertTrue(slot >= 0, "SaveManager::useSlot: Slot must be greater than or equal to 0");
this->currentSaveSlot = slot;
this->currentSave.reset();
}

View File

@ -11,7 +11,7 @@
using namespace Dawn;
Scene::Scene(DawnGame *game) {
assertNotNull(game);
assertNotNull(game, "Scene::Scene: Game cannot be null");
this->game = game;
this->nextId = 0;
this->physics = new ScenePhysicsManager(this);

View File

@ -60,7 +60,7 @@ namespace Dawn {
T * createSceneItemOfType() {
sceneitemid_t id = this->nextId++;
auto item = new T(this, id);
assertNotNull(item);
assertNotNull(item, "Scene::createSceneItemOfType: Failed to create SceneItem (Memory Filled?)");
this->itemsNotInitialized[id] = item;
return item;
}

View File

@ -9,7 +9,7 @@
using namespace Dawn;
SceneItem::SceneItem(Scene *scene, sceneitemid_t id) : transform(this) {
assertNotNull(scene);
assertNotNull(scene, "SceneItem::SceneItem: Scene cannot be null");
this->id = id;
this->scene = scene;

View File

@ -55,7 +55,7 @@ namespace Dawn {
template<class T>
T * addComponent() {
auto component = new T(this);
assertNotNull(component);
assertNotNull(component, "SceneItem::addComponent: Component could not be created (Memory filled?)");
this->components.push_back(component);
return component;
}

View File

@ -11,7 +11,7 @@
using namespace Dawn;
SceneItemComponent::SceneItemComponent(SceneItem *item) {
assertNotNull(item);
assertNotNull(item, "SceneItemComponent::SceneItemComponent: Item cannot be null");
this->item = item;
this->transform = &item->transform;
}

View File

@ -18,7 +18,7 @@ void FPSLabelComponent::onStart() {
if(this->label == nullptr) return;
std::string strFps = std::to_string((int32_t)(1.0f / delta));
std::string strTick = std::to_string((int32_t)(delta * 1000.0f));
assertUnreachable();// Needs updating to new UI Label
assertUnreachable("FPSLabelComponent::onStart: Not yet implemented");// Needs updating to new UI Label
// label->text = strFps + "FPS (" + strTick + "ms)";
}, this->item->scene->eventSceneUnpausedUpdate);
}

View File

@ -15,7 +15,7 @@ AnimationController::AnimationController(SceneItem *item) :
}
void AnimationController::addAnimation(Animation *animation) {
assertNotNull(animation);
assertNotNull(animation, "AnimationController::addAnimation: Animation cannot be null");
this->animations.push_back(animation);
}

View File

@ -43,7 +43,7 @@ void PixelPerfectCamera::updateDimensions() {
break;
default:
assertUnreachable();
assertUnreachable("PixelPerfectCamera::updateDimensions: Unknown camera type");
}
}

View File

@ -20,7 +20,7 @@ std::vector<SceneItemComponent*> SimpleRenderTargetQuad::getDependencies() {
}
void SimpleRenderTargetQuad::onStart() {
assertNotNull(this->meshHost);
assertNotNull(this->meshHost, "SimpleRenderTargetQuad::onStart: MeshHost cannot be null");
// Create quad mesh
this->meshHost->mesh.createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);

View File

@ -81,7 +81,7 @@ void TiledSprite::onStart() {
}
default:
assertUnreachable();
assertUnreachable("TiledSprite::onStart: Size type not implemented");
}
this->meshHost->xy0 = -quadSize;

View File

@ -25,8 +25,8 @@ bool_t SolidController2D::getCollidingResult(
glm::vec2 &entryPoint,
glm::vec2 &exitPoint
) {
assertNotNull(this->collider);
assertNotNull(movingObject);
assertNotNull(this->collider, "SolidController2D::getCollidingResult: Collider cannot be null");
assertNotNull(movingObject, "SolidController2D::getCollidingResult: Moving object cannot be null");
if(movement.x == 0 && movement.y == 0) return false;
auto myPos = physics3Dto2D(movingObject->transform->getWorldPosition());
@ -35,13 +35,13 @@ bool_t SolidController2D::getCollidingResult(
switch(movingObject->getColliderType()) {
case COLLIDER2D_TYPE_BOX: {
auto box1 = dynamic_cast<BoxCollider*>(movingObject);
assertNotNull(box1);
assertNotNull(box1, "SolidController2D::getCollidingResult: Moving object is not a BoxCollider");
// Box VS (this)?
switch(this->collider->getColliderType()) {
case COLLIDER2D_TYPE_BOX: {
auto box2 = dynamic_cast<BoxCollider*>(this->collider);
assertNotNull(box2);
assertNotNull(box2, "SolidController2D::getCollidingResult: Collider is not a BoxCollider");
auto otherPos = physics3Dto2D(box2->transform->getWorldPosition());
return boxCheckCollision(
@ -53,17 +53,17 @@ bool_t SolidController2D::getCollidingResult(
}
default: {
assertUnreachable();
assertUnreachable("SolidController2D::getCollidingResult: Collider type not implemented");
}
}
break;
}
default: {
assertUnreachable();
assertUnreachable("SolidController2D::getCollidingResult: Moving object type not implemented");
}
}
assertUnreachable();
assertUnreachable("SolidController2D::getCollidingResult: Should never reach this point");
return false;
}

View File

@ -18,19 +18,19 @@ std::vector<SceneItemComponent*> TriggerController2D::getDependencies() {
}
bool_t TriggerController2D::getCollidingResult(Collider2D* movingObject) {
assertNotNull(this->collider);
assertNotNull(movingObject);
assertNotNull(this->collider, "TriggerController2D::getCollidingResult: Collider cannot be null");
assertNotNull(movingObject, "TriggerController2D::getCollidingResult: Moving object cannot be null");
switch(movingObject->getColliderType()) {
case COLLIDER2D_TYPE_BOX: {
auto box1 = dynamic_cast<BoxCollider*>(movingObject);
assertNotNull(box1);
assertNotNull(box1, "TriggerController2D::getCollidingResult: Moving object is not a BoxCollider");
// Box VS ?
switch(collider->getColliderType()) {
case COLLIDER2D_TYPE_BOX: {
auto box2 = dynamic_cast<BoxCollider*>(collider);
assertNotNull(box2);
assertNotNull(box2, "TriggerController2D::getCollidingResult: Collider is not a BoxCollider");
return boxIsBoxColliding(
physics3Dto2D(box1->transform->getWorldPosition()), box1->min, box1->max,
physics3Dto2D(box2->transform->getWorldPosition()), box2->min, box2->max
@ -38,13 +38,13 @@ bool_t TriggerController2D::getCollidingResult(Collider2D* movingObject) {
}
default: {
assertUnreachable();
assertUnreachable("TriggerController2D::getCollidingResult: Collider type not implemented");
}
}
}
default: {
assertUnreachable();
assertUnreachable("TriggerController2D::getCollidingResult: Moving object type not implemented");
}
}
}

View File

@ -15,7 +15,7 @@ bool_t CapsuleCollider::performRaycast(
struct Collider3DRayResult *result,
struct Ray3D ray
) {
assertNotNull(result);
assertNotNull(result, "CapsuleCollider::performRaycast: Result cannot be null");
return raytestCapsule(
ray,

View File

@ -15,7 +15,7 @@ bool_t Collider3D::raycast(
struct Collider3DRayResult *result,
struct Ray3D ray
) {
assertNotNull(result);
assertNotNull(result, "Collider3D::raycast: Result cannot be null");
if(!this->performRaycast(result, ray)) return false;
result->collider = this;
return true;

View File

@ -15,7 +15,7 @@ bool_t CubeCollider::performRaycast(
struct Collider3DRayResult *result,
struct Ray3D ray
) {
assertNotNull(result);
assertNotNull(result, "CubeCollider::performRaycast: Result cannot be null");
return Dawn::raytestCube(
ray,

View File

@ -19,7 +19,7 @@ bool_t SphereCollider::performRaycast(
struct Collider3DRayResult *result,
struct Ray3D ray
) {
assertNotNull(result);
assertNotNull(result, "SphereCollider::performRaycast: Result cannot be null");
return raytestSphere(
ray,

View File

@ -40,7 +40,7 @@ void UICanvas::rebufferShaderParameters() {
break;
default:
assertUnreachable();
assertUnreachable("UICanvas::rebufferShaderParameters: Unknown draw type");
}
this->shaderBuffer.buffer(&data);

View File

@ -25,7 +25,7 @@ UIComponentDimensional * UIComponent::getParentDimensional() {
auto parent = this->transform->getParent();
if(parent == nullptr) return nullptr;
auto dimensional = parent->item->getComponent<UIComponentDimensional>();
assertNotNull(dimensional);
assertNotNull(dimensional, "UIComponent::getParentDimensional: Parent must have a UIComponentDimensional");
return dimensional;
}
@ -36,7 +36,7 @@ void UIComponent::updateAlignment() {
auto dimensional = this->getParentDimensional();
auto translate = this->transform->getLocalPosition();
assertNotNull(dimensional);
assertNotNull(dimensional, "UIComponent::updateAlignment: Parent must have a UIComponentDimensional");
parentInnerWidth = dimensional->getContentWidth();
parentInnerHeight = dimensional->getContentHeight();
@ -89,8 +89,8 @@ void UIComponent::calculateDimensions(
float_t innerSize,
glm::vec2 alignment
) {
assertNotNull(position);
assertNotNull(size);
assertNotNull(position, "UIComponent::calculateDimensions: Position cannot be null");
assertNotNull(size, "UIComponent::calculateDimensions: Size cannot be null");
switch(align) {
case UI_COMPONENT_ALIGN_STRETCH: {
@ -157,7 +157,7 @@ void UIComponent::calculateDimensions(
}
default:
assertUnreachable();
assertUnreachable("UIComponent::calculateDimensions: Unknown alignment");
break;
}
}
@ -170,7 +170,7 @@ UICanvas * UIComponent::getCanvas() {
if(canvas != nullptr) return canvas;
parent = parent->getParent();
}
assertUnreachable();
assertUnreachable("UIComponent::getCanvas: No canvas found");
return nullptr;
}

View File

@ -24,8 +24,8 @@ std::vector<SceneItemComponent*> UISimpleMenu::getDependencies() {
void UISimpleMenu::onStart() {
if(canvas == nullptr) canvas = getScene()->findComponent<UICanvas>();
assertNotNull(this->menu);
assertNotNull(this->canvas);
assertNotNull(this->menu, "UISimpleMenu::onStart: Menu cannot be null");
assertNotNull(this->canvas, "UISimpleMenu::onStart: Canvas cannot be null");
menuItems = this->item->findChildren<UISimpleMenuItem>();
auto updateSimpleMenuPos = [&](int32_t x, int32_t y) {
@ -59,7 +59,7 @@ void UISimpleMenu::onStart() {
}, menu->eventItemSelected);
useEvent([&](float_t d){
assertNotNull(canvas->camera);
assertNotNull(canvas->camera, "UISimpleMenu::onStart: Camera cannot be null");
if(!this->menu->active) return;
// Mouse in screen space.
@ -121,7 +121,7 @@ void UISimpleMenu::onStart() {
}
default: {
assertUnreachable();
assertUnreachable("UISimpleMenu::onStart: Draw type not implemented");
}
}
}, getScene()->eventSceneUnpausedUpdate);

View File

@ -72,7 +72,7 @@ std::vector<struct ShaderPassItem> UILabel::getUIRenderPasses() {
break;
default:
assertUnreachable();
assertUnreachable("UILabel::getUIRenderPasses: Texture slot not implemented");
}
item.textureSlots[it->second] = &it->first->texture;
@ -119,7 +119,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
return;
}
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX);
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX, "UILabel::rebufferQuads: Too many parts (not supported)");
int32_t nextTexture = 0;
glm::vec2 position(0, 0);
@ -161,17 +161,17 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
realText.style = text.style;
// Lock the font
assertNotNull(text.style.font);
assertNotNull(text.style.font, "UILabel::rebufferQuads: Font cannot be null");
realText.lockId = text.style.font->lock(TrueTypeFaceTextureStyle{
text.style.size,
text.style.style
});
assertTrue(realText.lockId != -1);
assertTrue(realText.lockId != -1, "UILabel::rebufferQuads: Failed to lock font");
realText.texture = text.style.font->getTexture(realText.lockId);
// Map texture
if(textureMap.find(realText.texture) == textureMap.end()) {
assertTrue(nextTexture < FONT_SHADER_TEXTURE_MAX);
assertTrue(nextTexture < FONT_SHADER_TEXTURE_MAX, "UILabel::rebufferQuads: Too many textures (not supported)");
textureMap[realText.texture] = nextTexture++;
}
@ -252,10 +252,10 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
}
// Validate characters
assertTrue(ch >= TRUE_TYPE_CHAR_BEGIN && ch < TRUE_TYPE_CHAR_END);
assertTrue(ch != '\r');
assertTrue(ch != '\t');
assertTrue(ch != '\n');
assertTrue(ch >= TRUE_TYPE_CHAR_BEGIN && ch < TRUE_TYPE_CHAR_END, "UILabel::rebufferQuads: Character out of range");
assertTrue(ch != '\r', "UILabel::rebufferQuads: Character cannot be a carriage return");
assertTrue(ch != '\t', "UILabel::rebufferQuads: Character cannot be a tab");
assertTrue(ch != '\n', "UILabel::rebufferQuads: Character cannot be a newline");
// Get font data.
auto charInfo = realText.texture->getCharacterData(ch);
@ -357,7 +357,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
);
if(hasDecorations) {
assertTrue(vertices.size() == decorations.size());
assertTrue(vertices.size() == decorations.size(), "UILabel::rebufferQuads: Decoration count mismatch");
this->meshDecorations.createBuffers(
QUAD_VERTICE_COUNT * decorations.size(),
QUAD_INDICE_COUNT * decorations.size()
@ -408,8 +408,8 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
// Finally, release the old locks
itText = textsBuffered.begin();
while(itText != textsBuffered.end()) {
assertTrue(itText->lockId != -1);
assertNotNull(itText->style.font);
assertTrue(itText->lockId != -1, "UILabel::rebufferQuads: Lock ID cannot be -1");
assertNotNull(itText->style.font, "UILabel::rebufferQuads: Font cannot be null");
itText->style.font->unlock(itText->lockId);
++itText;
}

View File

@ -39,7 +39,7 @@ void UIRichTextLabel::onStart() {
bufferTexts.push_back(text);
} else if(child.nodeType == XML_NODE_TYPE_ELEMENT) {
auto node = child.child;
assertTrue(node->node == "font");
assertTrue(node->node == "font", "UIRichTextLabel::onStart: Unknown node type '" + node->node + "'");
struct UILabelStyle style;
if(node->attributes.contains("font")) {

View File

@ -132,7 +132,7 @@ namespace Dawn {
// all the listeners on StateProperty<> that belong to this StateOwner
// I need to keep track of what events I've subbed to, consuming more
// memory, and I don't know if I actually need to do this or not.
assertTrue(property.owner == this);
assertTrue(property.owner == this, "StateOwner::useEffect: Property owner must be this StateOwner");
}
property._effectListners.push_back(fn);
return fn;
@ -156,7 +156,7 @@ namespace Dawn {
if(property->owner == nullptr) {
property->owner = this;
} else {
assertTrue(property->owner == this);
assertTrue(property->owner == this, "StateOwner::useEffect: Property owner must be this StateOwner");
}
property->_effectListners.push_back(fn);
++itProp;
@ -177,7 +177,11 @@ namespace Dawn {
const std::function<std::function<void()>()> &fn,
IStateProperty &property
) {
if(property.owner == nullptr) { property.owner = this; } else { assertTrue(property.owner == this); }
if(property.owner == nullptr) {
property.owner = this;
} else {
assertTrue(property.owner == this, "StateOwner::useEffectWithTeardown: Property owner must be this StateOwner");
}
property._effectListnersWithTeardown.push_back(fn);
return std::bind([&](

View File

@ -40,7 +40,7 @@ namespace Dawn {
auto unsub = std::bind([&](struct StateListener<D, A...> listener) {
// Not yet implemented
assertUnreachable();
assertUnreachable("StateProviderSet::addEffect: Not yet implemented");
}, l);
context->_stateProviderListeners.push_back(unsub);