mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
remove some ugly == NULL
This commit is contained in:
parent
911e77b725
commit
b2dccae86e
@ -141,7 +141,7 @@ static void Soundboard_Init(struct Soundboard* board, const String* boardName, S
|
||||
name = String_UNSAFE_Substring(&name, 0, name.length - 1);
|
||||
|
||||
struct SoundGroup* group = Soundboard_Find(board, &name);
|
||||
if (group == NULL) {
|
||||
if (!group) {
|
||||
if (board->Count == Array_Elems(board->Groups)) {
|
||||
Chat_AddRaw("&cCannot have more than 10 sound groups"); return;
|
||||
}
|
||||
@ -173,7 +173,7 @@ struct Sound* Soundboard_PickRandom(struct Soundboard* board, uint8_t type) {
|
||||
String name = String_FromReadonly(Sound_Names[type]);
|
||||
|
||||
struct SoundGroup* group = Soundboard_Find(board, &name);
|
||||
if (group == NULL) return NULL;
|
||||
if (!group) return NULL;
|
||||
int idx = Random_Range(&board->Rnd, 0, group->Count);
|
||||
return &group->Sounds[idx];
|
||||
}
|
||||
@ -229,7 +229,7 @@ static void Sounds_Play(uint8_t type, struct Soundboard* board) {
|
||||
if (type == SOUND_NONE || Game_SoundsVolume == 0) return;
|
||||
struct Sound* snd = Soundboard_PickRandom(board, type);
|
||||
|
||||
if (snd == NULL) return;
|
||||
if (!snd) return;
|
||||
struct AudioFormat fmt = snd->Format;
|
||||
int volume = Game_SoundsVolume;
|
||||
|
||||
|
@ -69,7 +69,9 @@ typedef struct Bitmap_ { uint8_t* Scan0; int Width, Height; } Bitmap;
|
||||
|
||||
#ifdef CC_BUILD_D3D9
|
||||
typedef void* GfxResourceID;
|
||||
#define GFX_NULL NULL
|
||||
#else
|
||||
typedef uint32_t GfxResourceID;
|
||||
#define GFX_NULL 0
|
||||
#endif
|
||||
#endif
|
||||
|
@ -47,10 +47,10 @@ static void D3D9_SetDefaultRenderStates(void);
|
||||
static void D3D9_RestoreRenderStates(void);
|
||||
|
||||
static void D3D9_FreeResource(GfxResourceID* resource) {
|
||||
if (resource == NULL || *resource == NULL) return;
|
||||
IUnknown* unk = (IUnknown*)(*resource);
|
||||
if (!resource || *resource == GFX_NULL) return;
|
||||
IUnknown* unk = (IUnknown*)(*resource);
|
||||
ULONG refCount = unk->lpVtbl->Release(unk);
|
||||
*resource = NULL;
|
||||
*resource = GFX_NULL;
|
||||
if (refCount <= 0) return;
|
||||
|
||||
uintptr_t addr = (uintptr_t)unk;
|
||||
|
@ -131,7 +131,7 @@ int Drawer2D_FontHeight(FontDesc* font, bool useShadow) {
|
||||
void Drawer2D_MakeTextTexture(struct Texture* tex, struct DrawTextArgs* args, int X, int Y) {
|
||||
Size2D size = Drawer2D_MeasureText(args);
|
||||
if (size.Width == 0 && size.Height == 0) {
|
||||
struct Texture empty = { NULL, TEX_RECT(X,Y, 0,0), TEX_UV(0,0, 1,1) };
|
||||
struct Texture empty = { GFX_NULL, TEX_RECT(X,Y, 0,0), TEX_UV(0,0, 1,1) };
|
||||
*tex = empty; return;
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ static void Player_MakeNameTexture(struct Player* player) {
|
||||
Size2D size = Drawer2D_MeasureText(&args);
|
||||
|
||||
if (size.Width == 0) {
|
||||
player->NameTex.ID = NULL;
|
||||
player->NameTex.ID = GFX_NULL;
|
||||
player->NameTex.X = PLAYER_NAME_EMPTY_TEX;
|
||||
} else {
|
||||
char buffer[STRING_SIZE];
|
||||
@ -589,7 +589,7 @@ static void Player_ApplySkin(struct Player* player, struct Player* from) {
|
||||
dst->vScale = src->vScale;
|
||||
|
||||
/* Custom mob textures */
|
||||
dst->MobTextureId = NULL;
|
||||
dst->MobTextureId = GFX_NULL;
|
||||
String skin = String_FromRawArray(dst->SkinNameRaw);
|
||||
if (Utils_IsUrlPrefix(&skin, 0)) { dst->MobTextureId = dst->TextureId; }
|
||||
}
|
||||
@ -597,8 +597,8 @@ static void Player_ApplySkin(struct Player* player, struct Player* from) {
|
||||
void Player_ResetSkin(struct Player* player) {
|
||||
struct Entity* entity = &player->Base;
|
||||
entity->uScale = 1.0f; entity->vScale = 1.0f;
|
||||
entity->MobTextureId = NULL;
|
||||
entity->TextureId = NULL;
|
||||
entity->MobTextureId = GFX_NULL;
|
||||
entity->TextureId = GFX_NULL;
|
||||
entity->SkinType = SKIN_64x32;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ bool Game_UpdateTexture(GfxResourceID* texId, struct Stream* src, const String*
|
||||
bool success = !res && Game_ValidateBitmap(file, &bmp);
|
||||
if (success) {
|
||||
Gfx_DeleteTexture(texId);
|
||||
if (skinType != NULL) { *skinType = Utils_GetSkinType(&bmp); }
|
||||
if (skinType) { *skinType = Utils_GetSkinType(&bmp); }
|
||||
*texId = Gfx_CreateTexture(&bmp, true, false);
|
||||
}
|
||||
|
||||
@ -679,7 +679,7 @@ static void Game_RenderFrame(double delta) {
|
||||
Gui_SetActive(PauseScreen_MakeInstance());
|
||||
}
|
||||
|
||||
bool allowZoom = Gui_Active == NULL && !Gui_HUD->HandlesAllInput;
|
||||
bool allowZoom = !Gui_Active && !Gui_HUD->HandlesAllInput;
|
||||
if (allowZoom && KeyBind_IsPressed(KeyBind_ZoomScrolling)) {
|
||||
InputHandler_SetFOV(Game_ZoomFov, false);
|
||||
}
|
||||
@ -693,7 +693,7 @@ static void Game_RenderFrame(double delta) {
|
||||
Game_CurrentCameraPos = Camera_Active->GetPosition(t);
|
||||
Game_UpdateViewMatrix();
|
||||
|
||||
bool visible = Gui_Active == NULL || !Gui_Active->BlocksWorld;
|
||||
bool visible = !Gui_Active || !Gui_Active->BlocksWorld;
|
||||
if (!World_Blocks) visible = false;
|
||||
if (visible) {
|
||||
Game_Render3D(delta, t);
|
||||
|
@ -129,7 +129,7 @@ struct Screen* Gui_GetActiveScreen(void) {
|
||||
}
|
||||
|
||||
struct Screen* Gui_GetUnderlyingScreen(void) {
|
||||
return Gui_Active == NULL ? Gui_HUD : Gui_Active;
|
||||
return Gui_Active ? Gui_Active : Gui_HUD;
|
||||
}
|
||||
|
||||
void Gui_FreeActive(void) {
|
||||
|
@ -141,7 +141,7 @@ void Model_UpdateVB(void) {
|
||||
void Model_ApplyTexture(struct Entity* entity) {
|
||||
struct Model* model = Model_ActiveModel;
|
||||
GfxResourceID tex = model->UsesHumanSkin ? entity->TextureId : entity->MobTextureId;
|
||||
if (tex != NULL) {
|
||||
if (tex) {
|
||||
Model_skinType = entity->SkinType;
|
||||
} else {
|
||||
struct CachedTexture* data = &ModelCache_Textures[model->defaultTexIndex];
|
||||
@ -150,7 +150,7 @@ void Model_ApplyTexture(struct Entity* entity) {
|
||||
}
|
||||
|
||||
Gfx_BindTexture(tex);
|
||||
bool _64x64 = Model_skinType != SKIN_64x32;
|
||||
bool _64x64 = Model_skinType != SKIN_64x32;
|
||||
Model_uScale = entity->uScale * 0.015625f;
|
||||
Model_vScale = entity->vScale * (_64x64 ? 0.015625f : 0.03125f);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void ModelCache_RegisterTexture(STRING_REF const char* texName) {
|
||||
if (ModelCache_texCount < MODELCACHE_MAX_MODELS) {
|
||||
struct CachedTexture tex;
|
||||
tex.Name = String_FromReadonly(texName);
|
||||
tex.TexID = NULL;
|
||||
tex.TexID = GFX_NULL;
|
||||
ModelCache_Textures[ModelCache_texCount++] = tex;
|
||||
} else {
|
||||
ErrorHandler_Fail("ModelCache_RegisterTexture - hit max textures");
|
||||
|
@ -178,9 +178,9 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
||||
}
|
||||
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
if (texId == NULL || *texId == NULL) return;
|
||||
if (!texId || *texId == GFX_NULL) return;
|
||||
glDeleteTextures(1, texId);
|
||||
*texId = NULL;
|
||||
*texId = GFX_NULL;
|
||||
}
|
||||
|
||||
void Gfx_SetTexturing(bool enabled) { gl_Toggle(GL_TEXTURE_2D); }
|
||||
@ -342,20 +342,20 @@ void Gfx_BindIb(GfxResourceID ib) {
|
||||
}
|
||||
|
||||
void Gfx_DeleteVb(GfxResourceID* vb) {
|
||||
if (vb == NULL || *vb == NULL) return;
|
||||
if (!vb || *vb == GFX_NULL) return;
|
||||
#ifndef CC_BUILD_GL11
|
||||
glDeleteBuffers(1, vb);
|
||||
#else
|
||||
if (*vb != gl_DYNAMICLISTID) glDeleteLists(*vb, 1);
|
||||
#endif
|
||||
*vb = NULL;
|
||||
*vb = GFX_NULL;
|
||||
}
|
||||
|
||||
void Gfx_DeleteIb(GfxResourceID* ib) {
|
||||
#ifndef CC_BUILD_GL11
|
||||
if (ib == NULL || *ib == NULL) return;
|
||||
if (!ib || *ib == GFX_NULL) return;
|
||||
glDeleteBuffers(1, ib);
|
||||
*ib = NULL;
|
||||
*ib = GFX_NULL;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
@ -142,7 +142,7 @@ void Options_Set(const char* keyRaw, const String* value) {
|
||||
|
||||
void Options_SetString(const String* key, const String* value) {
|
||||
int i;
|
||||
if (value == NULL || value->buffer == NULL) {
|
||||
if (!value || !value->length) {
|
||||
i = Options_Find(key);
|
||||
if (i >= 0) Options_Remove(i);
|
||||
} else {
|
||||
|
@ -522,7 +522,7 @@ static void LoadingScreen_DrawBackground(void) {
|
||||
TextureRec rec = Atlas1D_TexRec(texLoc, 1, &atlasIndex);
|
||||
|
||||
float u2 = (float)Game_Width / (float)LOADING_TILE_SIZE;
|
||||
struct Texture tex = { NULL, TEX_RECT(0,0, Game_Width,LOADING_TILE_SIZE), TEX_UV(0,rec.V1, u2,rec.V2) };
|
||||
struct Texture tex = { GFX_NULL, TEX_RECT(0,0, Game_Width,LOADING_TILE_SIZE), TEX_UV(0,rec.V1, u2,rec.V2) };
|
||||
|
||||
bool bound = false;
|
||||
while (y < Game_Height) {
|
||||
|
@ -17,7 +17,7 @@ void Atlas2D_UpdateState(Bitmap* bmp) {
|
||||
static GfxResourceID Atlas2D_LoadTextureElement_Raw(TextureLoc texLoc, Bitmap* element) {
|
||||
int size = Atlas2D_TileSize;
|
||||
int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc);
|
||||
if (y >= Atlas2D_RowsCount) return NULL;
|
||||
if (y >= Atlas2D_RowsCount) return GFX_NULL;
|
||||
|
||||
Bitmap_CopyBlock(x * size, y * size, 0, 0, &Atlas2D_Bitmap, element, size);
|
||||
return Gfx_CreateTexture(element, false, Gfx_Mipmaps);
|
||||
|
@ -95,9 +95,9 @@ void TextWidget_Set(struct TextWidget* w, const String* text, FontDesc* font) {
|
||||
#define BUTTON_uWIDTH (200.0f / 256.0f)
|
||||
#define BUTTON_MIN_WIDTH 40
|
||||
|
||||
struct Texture Button_ShadowTex = { NULL, TEX_RECT(0,0, 0,0), WIDGET_UV(0,66, 200,86) };
|
||||
struct Texture Button_SelectedTex = { NULL, TEX_RECT(0,0, 0,0), WIDGET_UV(0,86, 200,106) };
|
||||
struct Texture Button_DisabledTex = { NULL, TEX_RECT(0,0, 0,0), WIDGET_UV(0,46, 200,66) };
|
||||
struct Texture Button_ShadowTex = { GFX_NULL, TEX_RECT(0,0, 0,0), WIDGET_UV(0,66, 200,86) };
|
||||
struct Texture Button_SelectedTex = { GFX_NULL, TEX_RECT(0,0, 0,0), WIDGET_UV(0,86, 200,106) };
|
||||
struct Texture Button_DisabledTex = { GFX_NULL, TEX_RECT(0,0, 0,0), WIDGET_UV(0,46, 200,66) };
|
||||
|
||||
static void ButtonWidget_Free(void* widget) {
|
||||
struct ButtonWidget* w = widget;
|
||||
|
Loading…
x
Reference in New Issue
Block a user