Skip to content

Commit

Permalink
Merge remote-tracking branch 'eduke32/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendricks266 committed Dec 6, 2023
2 parents c6a7ed0 + 41c1761 commit fb7af7d
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 52 deletions.
14 changes: 0 additions & 14 deletions source/build/include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,20 +761,6 @@ void eduke32_exit_return(int) ATTRIBUTE((noreturn));
# define SCNx32 "x"
#endif

#if defined EDUKE32_OSX
# if !defined __x86_64__ && defined __GNUC__
// PK 20110617: is*() crashes for me in x86 code compiled from 64-bit, and gives link errors on ppc
// This hack patches all occurences.
# define isdigit(ch) ({ int32_t c__dontuse_=ch; c__dontuse_>='0' && c__dontuse_<='9'; })
# define isalpha(ch) ({ int32_t c__dontuse2_=ch; (c__dontuse2_>='A' && c__dontuse2_<='Z') || (c__dontuse2_>='a' && c__dontuse2_<='z'); })
# define isalnum(ch2) ({ int32_t c2__dontuse_=ch2; isalpha(c2__dontuse_) || isdigit(c2__dontuse_); })
# if defined __BIG_ENDIAN__
# define isspace(ch) ({ int32_t c__dontuse_=ch; (c__dontuse_==' ' || c__dontuse_=='\t' || c__dontuse_=='\n' || c__dontuse_=='\v' || c__dontuse_=='\f' || c__dontuse_=='\r'); })
# define isprint(ch) ({ int32_t c__dontuse_=ch; (c__dontuse_>=0x20 && c__dontuse_<0x7f); })
# endif
# endif
#endif


////////// Metaprogramming structs //////////

Expand Down
2 changes: 1 addition & 1 deletion source/build/src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10163,7 +10163,7 @@ static vec2_t GetCenterPoint(tspriteptr_t tspr) {

static int32_t GetCornerPoints(tspriteptr_t tspr, int32_t (&xx)[4], int32_t (&yy)[4])
{
bool const isOnFloor = (tspr->cstat & 32) != 0;
bool const isOnFloor = (tspr->cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) != 0;

if (isOnFloor)
{
Expand Down
2 changes: 1 addition & 1 deletion source/build/src/polymer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4121,7 +4121,7 @@ void polymer_updatesprite(int32_t snum)
if (pr_billboardingmode && alignmask == CSTAT_SPRITE_ALIGNMENT_FACING)
{
// do surgery on the face tspr to make it look like a wall sprite
tspr->cstat |= 16;
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_WALL;
tspr->ang = (fix16_to_int(viewangle) + 1024) & 2047;
}

Expand Down
4 changes: 2 additions & 2 deletions source/duke3d/src/astub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3894,7 +3894,7 @@ static void TextEntryMode(int16_t startspr)
return;
}

if ((sprite[startspr].cstat&16) == 0)
if ((sprite[startspr].cstat & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_WALL)
{
message("Must point at a wall-aligned text sprite.");
return;
Expand Down Expand Up @@ -10607,7 +10607,7 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, i
if (tspr->sectnum<0)
continue;

const int32_t wallaligned = (tspr->cstat & CSTAT_SPRITE_ALIGNMENT_WALL);
const int32_t wallaligned = (tspr->cstat & CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_WALL;
const int32_t fpal = sector[tspr->sectnum].floorpal;

// 1st rule
Expand Down
24 changes: 16 additions & 8 deletions source/duke3d/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,17 +1050,25 @@ char const * CONFIG_GetGameFuncOnKeyboard(int gameFunc)
return string0[0] == '\0' ? KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][1]) : string0;
}

const char mbtn_to_name[MAXMOUSEBUTTONS][2][32] = {
{"Left Mouse", "Double Left Mouse"},
{"Right Mouse", "Double Right Mouse"},
{"Middle Mouse", "Double Middle Mouse"},
{"Mouse 4", "Double Mouse 4"},
{"Wheel Up", ""},
{"Wheel Down", ""},
{"Mouse 5", "Double Mouse 5"},
{"Mouse 6", "Double Mouse 6"},
{"Mouse 7", "Double Mouse 7"},
{"Mouse 8", "Double Mouse 8"},
};

char const * CONFIG_GetGameFuncOnMouse(int gameFunc)
{
for (int j = 0; j < 2; ++j)
for (int i = 0; i < joystick.numButtons; ++i)
if (ud.config.JoystickFunctions[i][j] == gameFunc)
return joyGetName(1, i);

for (int i = 0; i < joystick.numAxes; ++i)
for (int j = 0; j < 2; ++j)
if (ud.config.JoystickDigitalFunctions[i][j] == gameFunc)
return joyGetName(0, i);
for (int i = 0; i < MAXMOUSEBUTTONS; ++i)
if (ud.config.MouseFunctions[i][j] == gameFunc)
return mbtn_to_name[i][j];

return "";
}
Expand Down
1 change: 1 addition & 0 deletions source/duke3d/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int32_t CONFIG_AnalogNameToNum(const char *func);
void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode key2, kb_scancode oldkey2);

const char * CONFIG_GetGameFuncOnKeyboard(int gameFunc);
const char * CONFIG_GetGameFuncOnMouse(int gameFunc);
const char * CONFIG_GetGameFuncOnJoystick(int gameFunc);

#endif
2 changes: 1 addition & 1 deletion source/duke3d/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3815,7 +3815,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
continue;
default:
// NOTE: wall-aligned sprites will never take on ceiling/floor shade...
if ((t->cstat&16) || (A_CheckEnemySprite(t) &&
if ((t->cstat & CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_WALL || (A_CheckEnemySprite(t) &&
(unsigned)t->owner < MAXSPRITES && sprite[t->owner].extra > 0) || t->statnum == STAT_PLAYER)
continue;
}
Expand Down
16 changes: 14 additions & 2 deletions source/duke3d/src/gameexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4116,6 +4116,7 @@ GAMEEXEC_STATIC void VM_Execute(int vm_execution_depth /*= false*/)

static char const s_KeyboardFormat[] = "[%s]";
static char const s_JoystickFormat[] = "(%s)";
static char const s_MouseFormat[] = "<%s>";
static char const s_Unbound[] = "UNBOUND";

auto getkeyname = [&](void)
Expand All @@ -4129,6 +4130,17 @@ GAMEEXEC_STATIC void VM_Execute(int vm_execution_depth /*= false*/)
return false;
};

auto getmousename = [&](void)
{
char const *mbutname = CONFIG_GetGameFuncOnMouse(gameFunc);
if (mbutname != nullptr && mbutname[0] != '\0')
{
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_MouseFormat, mbutname);
return true;
}
return false;
};

auto getjoyname = [&](void)
{
char const *joyname = CONFIG_GetGameFuncOnJoystick(gameFunc);
Expand All @@ -4142,12 +4154,12 @@ GAMEEXEC_STATIC void VM_Execute(int vm_execution_depth /*= false*/)

if (CONTROL_LastSeenInput == LastSeenInput::Joystick)
{
if (getjoyname() || getkeyname()) dispatch();
if (getjoyname() || getmousename() || getkeyname()) dispatch();
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_JoystickFormat, s_Unbound);
}
else
{
if (getkeyname() || getjoyname()) dispatch();
if (getmousename() || getkeyname() || getjoyname()) dispatch();
snprintf(apStrings[quoteIndex], MAXQUOTELEN, s_KeyboardFormat, s_Unbound);
}

Expand Down
16 changes: 8 additions & 8 deletions source/duke3d/src/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2503,16 +2503,16 @@ static void Menu_PopulateVideoSetup()
MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_BORDERLESS, newfullscreen);

#ifdef USE_OPENGL
auto const forbidClassic = (g_gameType & GAMEFLAG_NOCLASSIC) && rendermode != REND_CLASSIC;
#ifdef POLYMER
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_ALL, g_gameType & (GAMEFLAG_NOCLASSIC|GAMEFLAG_NOPOLYMER));
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_NOCLASSIC,
rendermode != REND_POLYMER && ((g_gameType & (GAMEFLAG_NOCLASSIC|GAMEFLAG_NOPOLYMER)) == (GAMEFLAG_NOCLASSIC|GAMEFLAG_NOPOLYMER)
|| !(g_gameType & GAMEFLAG_NOCLASSIC)));
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_NOPOLYMER,
rendermode != REND_CLASSIC && ((g_gameType & (GAMEFLAG_NOCLASSIC|GAMEFLAG_NOPOLYMER)) == (GAMEFLAG_NOCLASSIC|GAMEFLAG_NOPOLYMER)
|| !(g_gameType & GAMEFLAG_NOPOLYMER)));
auto const forbidPolymer = (g_gameType & GAMEFLAG_NOPOLYMER) && rendermode != REND_POLYMER;
auto const forbidNeither = !(g_gameType & (GAMEFLAG_NOCLASSIC|GAMEFLAG_NOPOLYMER));
auto const forbidBoth = forbidClassic && forbidPolymer;
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_ALL, forbidClassic || forbidPolymer);
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_NOCLASSIC, !forbidClassic || forbidNeither || forbidBoth);
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_NOPOLYMER, !forbidPolymer || forbidNeither || forbidBoth);
#else
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_ALL, rendermode != REND_CLASSIC && (g_gameType & GAMEFLAG_NOCLASSIC));
MenuEntry_HideOnCondition(&ME_VIDEOSETUP_RENDERER_ALL, forbidClassic);
#endif
#endif
}
Expand Down
33 changes: 18 additions & 15 deletions source/duke3d/src/startgtk.game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,26 @@ static void PopulateForm(unsigned char pgs)
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(stwidgets.vmode3dcombo)));
gtk_list_store_clear(modes3d);

for (i=0; i<validmodecnt; i++)
if (settings.grp != NULL)
{
if (settings.grp->type->game & GAMEFLAG_NOCLASSIC && validmode[i].bpp == 8) continue;
if (validmode[i].fs != settings.shared.fullscreen) continue;

// all modes get added to the 3D mode list
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim,
validmode[i].bpp == 8 ? "software"
: (settings.grp->type->game & GAMEFLAG_NOCLASSIC) ? ""
: "OpenGL");
gtk_list_store_append(modes3d, &iter);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d)
for (i=0; i<validmodecnt; i++)
{
g_signal_handlers_block_by_func(stwidgets.vmode3dcombo, (gpointer)on_vmode3dcombo_changed, NULL);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.vmode3dcombo), &iter);
g_signal_handlers_unblock_by_func(stwidgets.vmode3dcombo, (gpointer)on_vmode3dcombo_changed, NULL);
if (settings.grp->type->game & GAMEFLAG_NOCLASSIC && validmode[i].bpp == 8) continue;
if (validmode[i].fs != settings.shared.fullscreen) continue;

// all modes get added to the 3D mode list
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim,
validmode[i].bpp == 8 ? "software"
: (settings.grp->type->game & GAMEFLAG_NOCLASSIC) ? ""
: "OpenGL");
gtk_list_store_append(modes3d, &iter);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d)
{
g_signal_handlers_block_by_func(stwidgets.vmode3dcombo, (gpointer)on_vmode3dcombo_changed, NULL);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stwidgets.vmode3dcombo), &iter);
g_signal_handlers_unblock_by_func(stwidgets.vmode3dcombo, (gpointer)on_vmode3dcombo_changed, NULL);
}
}
}
}
Expand Down

0 comments on commit fb7af7d

Please sign in to comment.