Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1392-2-2-15-attempting-to-draw-a-hud-graphic-with-the-same-lump-name-as-a-lua-script-crashes-the
  • 21-installer-nodd
  • 2210-pre1
  • 2210-pre2
  • 2210-rc1
  • 2210-rc2
  • 2210-rc3
  • 2211-pre1
  • 2211-pre2
  • 2211-rc1
  • 2212-pre1
  • 2212-pre2
  • 2212-pre3
  • 2212-rc1
  • 2213
  • 2214-pre1
  • 2214-pre2
  • 2214-pre3
  • 2214-pre4
  • 2_2_12
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • acs
  • action-args
  • alpha-fixes
  • any-resolution
  • appveyor
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • bustablesoundz
  • cleanup-opengl
  • cleanupmusic
  • clipmidtex
  • cmake-valgrind
  • crawlacommander-sprites
  • custom-map-names
  • custom-teams
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delfile2
  • deprecate-lua-dedicated-server
  • dpl-2
  • dropshadows-spawning
  • dynabsp
  • emblem-drawing
  • exchndl-xp-fix
  • extra-textures
  • few-kart-lua-changes
  • ffloorclip
  • fix-167
  • fix-cvar-conflicts
  • fix-opengl-parameter-crash
  • fix-opengl-shear-roll
  • flipfuncpointers
  • fof-lightlist-fixes
  • font-FUCK
  • frictionrefactor
  • fuck-macros-1
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • gametype-refactor
  • gametype-refactor-1
  • gametype-refactor-player-spawns
  • ghost-networking
  • gif-splitting
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-maxconditionsets
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • just-in-case
  • keycodes-only
  • ksf-wadfiles
  • ld413-mp-fix
  • levelstruct
  • libpng-version-support
  • linedef-actions
  • lj-test
  • lol-states
  • loopedsounds
  • lower-unpegged-fix
  • lua-change-gametype
  • lua-command-netids
  • lua-gfx-2
  • lua-gfx-sprites
  • lua-local
  • makefile-auto-mingw-gcc
  • makefile-tinkering
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.10
  • SRB2_release_2.2.11
  • SRB2_release_2.2.12
  • SRB2_release_2.2.13
  • SRB2_release_2.2.15
  • SRB2_release_2.2.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • SRB2_release_2.2.7
  • SRB2_release_2.2.8
  • SRB2_release_2.2.9
  • td-release-v1.0.0
142 results

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
  • 21-installer-nodd
  • 2210-pre1
  • 2210-pre2
  • 2210-rc1
  • 2210-rc2
  • 2210-rc3
  • 2211-pre1
  • 2211-pre2
  • 2211-rc1
  • 2212-pre1
  • 2212-pre2
  • 2212-pre3
  • 2212-rc1
  • 2213
  • 2_2_12
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • acs
  • action-args
  • alpha-fixes
  • any-resolution
  • appveyor
  • better-player-states
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • bustablesoundz
  • camera-think-hook
  • cleanup-opengl
  • cleanupmusic
  • cmake-valgrind
  • crawlacommander-sprites
  • custom-map-names
  • custom-teams
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delfile2
  • deprecate-lua-dedicated-server
  • dpl-2
  • dropshadows-spawning
  • dynabsp
  • emblem-drawing
  • exchndl-xp-fix
  • few-kart-lua-changes
  • ffloorclip
  • fix-1215
  • fix-167
  • fix-cvar-conflicts
  • fix-equation-slopes-near-edges
  • fix-opengl-shear-roll
  • flipfuncpointers
  • fof-lightlist-fixes
  • font-FUCK
  • frictionrefactor
  • fuck-macros-1
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • gametype-refactor
  • gametype-refactor-1
  • gametype-refactor-player-spawns
  • ghost-networking
  • gif-splitting
  • gitlab-ci
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • keycodes-only
  • ksf-wadfiles
  • ld413-mp-fix
  • levelstruct
  • libpng-version-support
  • linedef-actions
  • lj-test
  • lol-states
  • loopedsounds
  • lower-unpegged-fix
  • lua-change-gametype
  • lua-command-netids
  • lua-conditions
  • lua-debug-library
  • lua-gfx-2
  • lua-gfx-sprites
  • lua-local
  • makefile-auto-mingw-gcc
  • makefile-tinkering
  • map-components-signedness-fixes
  • master
  • menu-edits
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.10
  • SRB2_release_2.2.11
  • SRB2_release_2.2.12
  • SRB2_release_2.2.13
  • SRB2_release_2.2.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • SRB2_release_2.2.7
  • SRB2_release_2.2.8
  • SRB2_release_2.2.9
  • td-release-v1.0.0
141 results
Show changes
Showing with 406 additions and 123 deletions
...@@ -69,6 +69,7 @@ enum sector_e { ...@@ -69,6 +69,7 @@ enum sector_e {
sector_triggerer, sector_triggerer,
sector_friction, sector_friction,
sector_gravity, sector_gravity,
sector_customargs
}; };
static const char *const sector_opt[] = { static const char *const sector_opt[] = {
...@@ -112,6 +113,7 @@ static const char *const sector_opt[] = { ...@@ -112,6 +113,7 @@ static const char *const sector_opt[] = {
"triggerer", "triggerer",
"friction", "friction",
"gravity", "gravity",
"customargs",
NULL}; NULL};
static int sector_fields_ref = LUA_NOREF; static int sector_fields_ref = LUA_NOREF;
...@@ -147,6 +149,7 @@ enum line_e { ...@@ -147,6 +149,7 @@ enum line_e {
line_taglist, line_taglist,
line_args, line_args,
line_stringargs, line_stringargs,
line_customargs,
line_sidenum, line_sidenum,
line_frontside, line_frontside,
line_backside, line_backside,
...@@ -173,6 +176,7 @@ static const char *const line_opt[] = { ...@@ -173,6 +176,7 @@ static const char *const line_opt[] = {
"taglist", "taglist",
"args", "args",
"stringargs", "stringargs",
"customargs",
"sidenum", "sidenum",
"frontside", "frontside",
"backside", "backside",
...@@ -221,7 +225,8 @@ enum side_e { ...@@ -221,7 +225,8 @@ enum side_e {
side_lightabsolute_top, side_lightabsolute_top,
side_lightabsolute_mid, side_lightabsolute_mid,
side_lightabsolute_bottom, side_lightabsolute_bottom,
side_text side_text,
side_customargs
}; };
static const char *const side_opt[] = { static const char *const side_opt[] = {
...@@ -258,6 +263,7 @@ static const char *const side_opt[] = { ...@@ -258,6 +263,7 @@ static const char *const side_opt[] = {
"lightabsolute_mid", "lightabsolute_mid",
"lightabsolute_bottom", "lightabsolute_bottom",
"text", "text",
"customargs",
NULL}; NULL};
static int side_fields_ref = LUA_NOREF; static int side_fields_ref = LUA_NOREF;
...@@ -674,6 +680,73 @@ static int sectorlines_num(lua_State *L) ...@@ -674,6 +680,73 @@ static int sectorlines_num(lua_State *L)
return 1; return 1;
} }
//////////////////
// customargs_t //
//////////////////
FUNCINLINE static ATTRINLINE int customargs_get(lua_State* L, const char* meta)
{
customargs_t *args = *((customargs_t**)luaL_checkudata(L, 1, meta));
const char* field = luaL_checkstring(L, 2);
if (args == NULL) {
lua_pushnil(L);
return 1;
}
customargs_t* current = args;
while (current != NULL)
{
if (!strcmp(current->name, field))
{
switch (current->type)
{
case UDMF_TYPE_STRING:
lua_pushstring(L, current->value.vstring);
break;
case UDMF_TYPE_NUMERIC:
lua_pushinteger(L, current->value.vint);
break;
case UDMF_TYPE_FIXED:
lua_pushfixed(L, current->value.vfloat);
break;
case UDMF_TYPE_BOOLEAN:
lua_pushboolean(L, current->value.vbool);
break;
default:
lua_pushnil(L);
}
return 1;
}
current = current->next;
}
lua_pushnil(L);
return 1;
}
static int sectorcustomargs_get(lua_State* L)
{
return customargs_get(L, META_SECTORCUSTOMARGS);
}
static int sidecustomargs_get(lua_State* L)
{
return customargs_get(L, META_SIDECUSTOMARGS);
}
static int linecustomargs_get(lua_State* L)
{
return customargs_get(L, META_LINECUSTOMARGS);
}
static int thingcustomargs_get(lua_State* L)
{
return customargs_get(L, META_THINGCUSTOMARGS);
}
////////////// //////////////
// sector_t // // sector_t //
////////////// //////////////
...@@ -835,6 +908,9 @@ static int sector_get(lua_State *L) ...@@ -835,6 +908,9 @@ static int sector_get(lua_State *L)
case sector_gravity: // gravity case sector_gravity: // gravity
lua_pushfixed(L, sector->gravity); lua_pushfixed(L, sector->gravity);
return 1; return 1;
case sector_customargs:
LUA_PushUserdata(L, sector->customargs, META_SECTORCUSTOMARGS);
return 1;
} }
return 0; return 0;
} }
...@@ -1130,6 +1206,9 @@ static int line_get(lua_State *L) ...@@ -1130,6 +1206,9 @@ static int line_get(lua_State *L)
case line_stringargs: case line_stringargs:
LUA_PushUserdata(L, line->stringargs, META_LINESTRINGARGS); LUA_PushUserdata(L, line->stringargs, META_LINESTRINGARGS);
return 1; return 1;
case line_customargs:
LUA_PushUserdata(L, line->customargs, META_LINECUSTOMARGS);
return 1;
case line_sidenum: case line_sidenum:
LUA_PushUserdata(L, line->sidenum, META_SIDENUM); LUA_PushUserdata(L, line->sidenum, META_SIDENUM);
return 1; return 1;
...@@ -1351,6 +1430,9 @@ static int side_get(lua_State *L) ...@@ -1351,6 +1430,9 @@ static int side_get(lua_State *L)
case side_lightabsolute_bottom: case side_lightabsolute_bottom:
lua_pushboolean(L, side->lightabsolute_bottom); lua_pushboolean(L, side->lightabsolute_bottom);
return 1; return 1;
case side_customargs:
LUA_PushUserdata(L, side->customargs, META_SIDECUSTOMARGS);
return 1;
// TODO: 2.3: Delete // TODO: 2.3: Delete
case side_text: case side_text:
{ {
...@@ -1370,6 +1452,7 @@ static int side_get(lua_State *L) ...@@ -1370,6 +1452,7 @@ static int side_get(lua_State *L)
return 1; return 1;
} }
} }
return 0; return 0;
} }
...@@ -3061,9 +3144,12 @@ int LUA_MapLib(lua_State *L) ...@@ -3061,9 +3144,12 @@ int LUA_MapLib(lua_State *L)
LUA_RegisterUserdataMetatable(L, META_SECTORLINES, sectorlines_get, NULL, sectorlines_num); LUA_RegisterUserdataMetatable(L, META_SECTORLINES, sectorlines_get, NULL, sectorlines_num);
LUA_RegisterUserdataMetatable(L, META_SECTOR, sector_get, sector_set, sector_num); LUA_RegisterUserdataMetatable(L, META_SECTOR, sector_get, sector_set, sector_num);
LUA_RegisterUserdataMetatable(L, META_SUBSECTOR, subsector_get, NULL, subsector_num); LUA_RegisterUserdataMetatable(L, META_SUBSECTOR, subsector_get, NULL, subsector_num);
LUA_RegisterUserdataMetatable(L, META_SECTORCUSTOMARGS, sectorcustomargs_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_LINE, line_get, NULL, line_num); LUA_RegisterUserdataMetatable(L, META_LINE, line_get, NULL, line_num);
LUA_RegisterUserdataMetatable(L, META_LINEARGS, lineargs_get, NULL, lineargs_len); LUA_RegisterUserdataMetatable(L, META_LINEARGS, lineargs_get, NULL, lineargs_len);
LUA_RegisterUserdataMetatable(L, META_LINESTRINGARGS, linestringargs_get, NULL, linestringargs_len); LUA_RegisterUserdataMetatable(L, META_LINESTRINGARGS, linestringargs_get, NULL, linestringargs_len);
LUA_RegisterUserdataMetatable(L, META_LINECUSTOMARGS, linecustomargs_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SIDECUSTOMARGS, sidecustomargs_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SIDENUM, sidenum_get, NULL, NULL); LUA_RegisterUserdataMetatable(L, META_SIDENUM, sidenum_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_SIDE, side_get, side_set, side_num); LUA_RegisterUserdataMetatable(L, META_SIDE, side_get, side_set, side_num);
LUA_RegisterUserdataMetatable(L, META_VERTEX, vertex_get, NULL, vertex_num); LUA_RegisterUserdataMetatable(L, META_VERTEX, vertex_get, NULL, vertex_num);
...@@ -3073,6 +3159,7 @@ int LUA_MapLib(lua_State *L) ...@@ -3073,6 +3159,7 @@ int LUA_MapLib(lua_State *L)
LUA_RegisterUserdataMetatable(L, META_VECTOR2, vector2_get, NULL, NULL); LUA_RegisterUserdataMetatable(L, META_VECTOR2, vector2_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_VECTOR3, vector3_get, NULL, NULL); LUA_RegisterUserdataMetatable(L, META_VECTOR3, vector3_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_MAPHEADER, mapheaderinfo_get, NULL, NULL); LUA_RegisterUserdataMetatable(L, META_MAPHEADER, mapheaderinfo_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_THINGCUSTOMARGS, thingcustomargs_get, NULL, NULL);
sector_fields_ref = Lua_CreateFieldTable(L, sector_opt); sector_fields_ref = Lua_CreateFieldTable(L, sector_opt);
subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt); subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt);
......
...@@ -973,6 +973,7 @@ enum mapthing_e { ...@@ -973,6 +973,7 @@ enum mapthing_e {
mapthing_taglist, mapthing_taglist,
mapthing_args, mapthing_args,
mapthing_stringargs, mapthing_stringargs,
mapthing_customargs,
mapthing_mobj, mapthing_mobj,
}; };
...@@ -994,6 +995,7 @@ const char *const mapthing_opt[] = { ...@@ -994,6 +995,7 @@ const char *const mapthing_opt[] = {
"taglist", "taglist",
"args", "args",
"stringargs", "stringargs",
"customargs",
"mobj", "mobj",
NULL, NULL,
}; };
...@@ -1072,6 +1074,9 @@ static int mapthing_get(lua_State *L) ...@@ -1072,6 +1074,9 @@ static int mapthing_get(lua_State *L)
case mapthing_stringargs: case mapthing_stringargs:
LUA_PushUserdata(L, mt->stringargs, META_THINGSTRINGARGS); LUA_PushUserdata(L, mt->stringargs, META_THINGSTRINGARGS);
break; break;
case mapthing_customargs:
LUA_PushUserdata(L, mt->customargs, META_THINGCUSTOMARGS);
break;
case mapthing_mobj: case mapthing_mobj:
LUA_PushUserdata(L, mt->mobj, META_MOBJ); LUA_PushUserdata(L, mt->mobj, META_MOBJ);
break; break;
......
...@@ -62,6 +62,7 @@ static lua_CFunction liblist[] = { ...@@ -62,6 +62,7 @@ static lua_CFunction liblist[] = {
LUA_HudLib, // HUD stuff LUA_HudLib, // HUD stuff
LUA_ColorLib, // general color functions LUA_ColorLib, // general color functions
LUA_InputLib, // inputs LUA_InputLib, // inputs
LUA_InterceptLib, // intercept_t
NULL NULL
}; };
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "p_setup.h" #include "p_setup.h"
#include "f_finale.h" #include "f_finale.h"
#include "lua_hook.h" #include "lua_hook.h"
#include "lua_libs.h"
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_main.h" #include "hardware/hw_main.h"
...@@ -3793,6 +3794,7 @@ void M_ClearMenus(boolean callexitmenufunc) ...@@ -3793,6 +3794,7 @@ void M_ClearMenus(boolean callexitmenufunc)
hidetitlemap = false; hidetitlemap = false;
I_UpdateMouseGrab(); I_UpdateMouseGrab();
I_SetTextInputMode(textinputmodeenabledbylua);
} }
// //
...@@ -11141,37 +11143,11 @@ static INT32 menuRoomIndex = 0; ...@@ -11141,37 +11143,11 @@ static INT32 menuRoomIndex = 0;
static void M_DrawRoomMenu(void) static void M_DrawRoomMenu(void)
{ {
static fixed_t frame = -(12 << FRACBITS);
int dot_frame;
char text[4];
const char *rmotd; const char *rmotd;
const char *waiting_message; const char *waiting_message;
int dots;
if (m_waiting_mode) if (m_waiting_mode)
{ currentMenu->menuitems[0].text = "...";
dot_frame = (int)(frame >> FRACBITS) / 4;
dots = dot_frame + 3;
strcpy(text, " ");
if (dots > 0)
{
if (dot_frame < 0)
dot_frame = 0;
if (dot_frame != 3)
strncpy(&text[dot_frame], "...", min(dots, 3 - dot_frame));
}
frame += renderdeltatics;
while (frame >= (12 << FRACBITS))
frame -= 12 << FRACBITS;
currentMenu->menuitems[0].text = text;
}
// use generic drawer for cursor, items and title // use generic drawer for cursor, items and title
M_DrawGenericMenu(); M_DrawGenericMenu();
......
...@@ -1720,7 +1720,7 @@ char *va(const char *format, ...) ...@@ -1720,7 +1720,7 @@ char *va(const char *format, ...)
static char string[1024]; static char string[1024];
va_start(argptr, format); va_start(argptr, format);
vsprintf(string, format, argptr); vsnprintf(string, 1024, format, argptr);
va_end(argptr); va_end(argptr);
return string; return string;
......
...@@ -127,8 +127,8 @@ perfstatrow_t commoncounter_rows[] = { ...@@ -127,8 +127,8 @@ perfstatrow_t commoncounter_rows[] = {
}; };
perfstatrow_t interpolation_rows[] = { perfstatrow_t interpolation_rows[] = {
{"intpfrc", "Interp frac: ", &ps_interp_frac, PS_TIME}, {"intpfrc", "Interp frac: ", &ps_interp_frac, 0}, // PS_TIME is not applicable here, as it is meant for I_GetPreciseTime
{"intplag", "Interp lag: ", &ps_interp_lag, PS_TIME}, {"intplag", "Interp lag: ", &ps_interp_lag, 0},
{0} {0}
}; };
......
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 2013-2024 by Sonic Team Junior. // Copyright (C) 2013-2025 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
...@@ -28,6 +28,7 @@ tokenizer_t *Tokenizer_Open(const char *inputString, size_t len, unsigned numTok ...@@ -28,6 +28,7 @@ tokenizer_t *Tokenizer_Open(const char *inputString, size_t len, unsigned numTok
tokenizer->endPos = 0; tokenizer->endPos = 0;
tokenizer->inputLength = 0; tokenizer->inputLength = 0;
tokenizer->inComment = 0; tokenizer->inComment = 0;
tokenizer->stringNeedsEscaping = false;
tokenizer->inString = 0; tokenizer->inString = 0;
tokenizer->get = Tokenizer_Read; tokenizer->get = Tokenizer_Read;
...@@ -92,6 +93,124 @@ static void DetectComment(tokenizer_t *tokenizer, UINT32 *pos) ...@@ -92,6 +93,124 @@ static void DetectComment(tokenizer_t *tokenizer, UINT32 *pos)
tokenizer->inComment = 2; tokenizer->inComment = 2;
} }
// This function detects escape sequences in a string and attempts to convert them.
static size_t EscapeString(char *output, const char *input, size_t inputLength)
{
const char *end = input + inputLength;
size_t i = 0;
while (input < end)
{
char chr = *input++;
if (chr == '\\')
{
chr = *input++;
switch (chr)
{
case 'n':
output[i] = '\n';
i++;
break;
case 't':
output[i] = '\t';
i++;
break;
case '\\':
output[i] = '\\';
i++;
break;
case '"':
output[i] = '\"';
i++;
break;
case 'x': {
int out = 0, c;
int j = 0;
chr = *input++;
for (j = 0; j < 5 && isxdigit(chr); j++)
{
c = ((chr <= '9') ? (chr - '0') : (tolower(chr) - 'a' + 10));
out = (out << 4) | c;
chr = *input++;
}
input--;
switch (j)
{
case 4:
output[i] = (out >> 8) & 0xFF;
i++;
/* FALLTHRU */
case 2:
output[i] = out & 0xFF;
i++;
break;
default:
// TODO: Displaying parsing errors properly will require
// some refactoring of the tokenizer itself. For now,
// this function will silently return an empty string
// if it encounters a malformed escape sequence.
// This situation cannot happen for i.e. UDMF comments,
// so it's okay to do this right now.
// CONS_Alert(CONS_WARNING, "Escape sequence has wrong size\n");
i = 0;
goto done;
}
break;
}
default:
if (isdigit(chr))
{
int out = 0;
int j = 0;
do
{
out = 10*out + (chr - '0');
chr = *input++;
} while (++j < 3 && isdigit(chr));
input--;
if (out > 255)
{
// CONS_Alert(CONS_WARNING, "Escape sequence is too large\n");
i = 0;
goto done;
}
output[i] = out;
i++;
}
else
{
// CONS_Alert(CONS_WARNING, "Unknown escape sequence '\\%c'\n", chr);
i = 0;
goto done;
}
break;
}
}
else
{
output[i] = chr;
i++;
}
}
done:
output[i] = '\0';
i++;
return i;
}
static void Tokenizer_ReadTokenString(tokenizer_t *tokenizer, UINT32 i) static void Tokenizer_ReadTokenString(tokenizer_t *tokenizer, UINT32 i)
{ {
UINT32 tokenLength = tokenizer->endPos - tokenizer->startPos; UINT32 tokenLength = tokenizer->endPos - tokenizer->startPos;
...@@ -101,10 +220,46 @@ static void Tokenizer_ReadTokenString(tokenizer_t *tokenizer, UINT32 i) ...@@ -101,10 +220,46 @@ static void Tokenizer_ReadTokenString(tokenizer_t *tokenizer, UINT32 i)
// Assign the memory. Don't forget an extra byte for the end of the string! // Assign the memory. Don't forget an extra byte for the end of the string!
tokenizer->token[i] = (char *)Z_Malloc(tokenizer->capacity[i] * sizeof(char), PU_STATIC, NULL); tokenizer->token[i] = (char *)Z_Malloc(tokenizer->capacity[i] * sizeof(char), PU_STATIC, NULL);
} }
// Copy the string. // Copy the string.
M_Memcpy(tokenizer->token[i], tokenizer->input + tokenizer->startPos, (size_t)tokenLength); if (tokenizer->stringNeedsEscaping)
// Make the final character NUL. {
tokenizer->token[i][tokenLength] = '\0'; EscapeString(tokenizer->token[i], tokenizer->input + tokenizer->startPos, (size_t)tokenLength);
}
else
{
M_Memcpy(tokenizer->token[i], tokenizer->input + tokenizer->startPos, (size_t)tokenLength);
// Make the final character NUL.
tokenizer->token[i][tokenLength] = '\0';
}
}
static void ScanString(tokenizer_t *tokenizer)
{
tokenizer->stringNeedsEscaping = false;
while (tokenizer->input[tokenizer->endPos] != '"' && tokenizer->endPos < tokenizer->inputLength)
{
if (!DetectLineBreak(tokenizer, tokenizer->endPos))
{
// Skip one character ahead if this looks like an escape sequence
if (tokenizer->input[tokenizer->endPos] == '\\')
{
tokenizer->stringNeedsEscaping = true;
tokenizer->endPos++;
// Oh. Naughty. We hit the end of the input.
// Stop scanning, then.
if (tokenizer->endPos == tokenizer->inputLength)
return;
DetectLineBreak(tokenizer, tokenizer->endPos);
}
}
tokenizer->endPos++;
}
} }
const char *Tokenizer_Read(tokenizer_t *tokenizer, UINT32 i) const char *Tokenizer_Read(tokenizer_t *tokenizer, UINT32 i)
...@@ -117,11 +272,7 @@ const char *Tokenizer_Read(tokenizer_t *tokenizer, UINT32 i) ...@@ -117,11 +272,7 @@ const char *Tokenizer_Read(tokenizer_t *tokenizer, UINT32 i)
// If in a string, return the entire string within quotes, except without the quotes. // If in a string, return the entire string within quotes, except without the quotes.
if (tokenizer->inString == 1) if (tokenizer->inString == 1)
{ {
while (tokenizer->input[tokenizer->endPos] != '"' && tokenizer->endPos < tokenizer->inputLength) ScanString(tokenizer);
{
DetectLineBreak(tokenizer, tokenizer->endPos);
tokenizer->endPos++;
}
Tokenizer_ReadTokenString(tokenizer, i); Tokenizer_ReadTokenString(tokenizer, i);
tokenizer->inString = 2; tokenizer->inString = 2;
...@@ -134,6 +285,7 @@ const char *Tokenizer_Read(tokenizer_t *tokenizer, UINT32 i) ...@@ -134,6 +285,7 @@ const char *Tokenizer_Read(tokenizer_t *tokenizer, UINT32 i)
tokenizer->token[i][0] = tokenizer->input[tokenizer->startPos]; tokenizer->token[i][0] = tokenizer->input[tokenizer->startPos];
tokenizer->token[i][1] = '\0'; tokenizer->token[i][1] = '\0';
tokenizer->inString = 0; tokenizer->inString = 0;
tokenizer->stringNeedsEscaping = false;
return tokenizer->token[i]; return tokenizer->token[i];
} }
...@@ -281,11 +433,7 @@ const char *Tokenizer_SRB2Read(tokenizer_t *tokenizer, UINT32 i) ...@@ -281,11 +433,7 @@ const char *Tokenizer_SRB2Read(tokenizer_t *tokenizer, UINT32 i)
else if (tokenizer->input[tokenizer->startPos] == '"') else if (tokenizer->input[tokenizer->startPos] == '"')
{ {
tokenizer->endPos = ++tokenizer->startPos; tokenizer->endPos = ++tokenizer->startPos;
while (tokenizer->input[tokenizer->endPos] != '"' && tokenizer->endPos < tokenizer->inputLength) ScanString(tokenizer);
{
DetectLineBreak(tokenizer, tokenizer->endPos);
tokenizer->endPos++;
}
Tokenizer_ReadTokenString(tokenizer, i); Tokenizer_ReadTokenString(tokenizer, i);
tokenizer->endPos++; tokenizer->endPos++;
......
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 2013-2024 by Sonic Team Junior. // Copyright (C) 2013-2025 by Sonic Team Junior.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
...@@ -26,6 +26,7 @@ typedef struct Tokenizer ...@@ -26,6 +26,7 @@ typedef struct Tokenizer
UINT32 inputLength; UINT32 inputLength;
UINT8 inComment; // 0 = not in comment, 1 = // Single-line, 2 = /* Multi-line */ UINT8 inComment; // 0 = not in comment, 1 = // Single-line, 2 = /* Multi-line */
UINT8 inString; // 0 = not in string, 1 = in string, 2 = just left string UINT8 inString; // 0 = not in string, 1 = in string, 2 = just left string
boolean stringNeedsEscaping;
int line; int line;
const char *(*get)(struct Tokenizer*, UINT32); const char *(*get)(struct Tokenizer*, UINT32);
} tokenizer_t; } tokenizer_t;
......
...@@ -54,6 +54,8 @@ static boolean IsDownloadingFile(void) ...@@ -54,6 +54,8 @@ static boolean IsDownloadingFile(void)
static void DrawConnectionStatusBox(void) static void DrawConnectionStatusBox(void)
{ {
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1);
if (cl_mode != CL_DOWNLOADSAVEGAME && filedownload.current != -1)
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-46-8, 32, 1);
if (cl_mode == CL_CONFIRMCONNECT || IsDownloadingFile()) if (cl_mode == CL_CONFIRMCONNECT || IsDownloadingFile())
return; return;
...@@ -84,6 +86,33 @@ static void DrawFileProgress(fileneeded_t *file, int y) ...@@ -84,6 +86,33 @@ static void DrawFileProgress(fileneeded_t *file, int y)
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, y, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, y, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024));
} }
static void DrawOverallProgress(int y)
{
UINT32 totalsize = filedownload.totalsize;
INT32 downloadedfiles = filedownload.completednum;
INT32 totalfiles = filedownload.remaining + filedownload.completednum;
INT32 downloaded = filedownload.completedsize;
if (fileneeded[filedownload.current].currentsize != fileneeded[filedownload.current].totalsize)
downloaded = filedownload.completedsize + fileneeded[filedownload.current].currentsize;
INT32 dldlength = (INT32)((downloaded/(double)totalsize) * 256);
if (dldlength > 256)
dldlength = 256;
V_DrawFill(BASEVIDWIDTH/2-128, y, 256, 8, 111);
V_DrawFill(BASEVIDWIDTH/2-128, y, dldlength, 8, 96);
const char *progress_str;
if (totalsize >= 1024*1024)
progress_str = va(" %.2fMiB/%.2fMiB", (double)downloaded / (1024*1024), (double)totalsize / (1024*1024));
else if (totalsize < 1024)
progress_str = va(" %4uB/%4uB", downloaded, totalsize);
else
progress_str = va(" %.2fKiB/%.2fKiB", (double)downloaded / 1024, (double)totalsize / 1024);
V_DrawString(BASEVIDWIDTH/2-128, y, V_20TRANS|V_ALLOWLOWERCASE, progress_str);
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, y, V_20TRANS|V_ALLOWLOWERCASE, va("%2u/%2u Files ", downloadedfiles+1, totalfiles));
}
// //
// CL_DrawConnectionStatus // CL_DrawConnectionStatus
// //
...@@ -96,7 +125,7 @@ static void CL_DrawConnectionStatus(void) ...@@ -96,7 +125,7 @@ static void CL_DrawConnectionStatus(void)
// Draw background fade // Draw background fade
V_DrawFadeScreen(0xFF00, 16); // force default V_DrawFadeScreen(0xFF00, 16); // force default
if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_DOWNLOADHTTPFILES && cl_mode != CL_LOADFILES) if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_DOWNLOADHTTPFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES && cl_mode != CL_ASKFULLFILELIST)
{ {
INT32 animtime = ((ccstime / 4) & 15) + 16; INT32 animtime = ((ccstime / 4) & 15) + 16;
UINT8 palstart; UINT8 palstart;
...@@ -179,6 +208,31 @@ static void CL_DrawConnectionStatus(void) ...@@ -179,6 +208,31 @@ static void CL_DrawConnectionStatus(void)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE,
va(" %2u/%2u files",loadcompletednum,fileneedednum)); va(" %2u/%2u files",loadcompletednum,fileneedednum));
} }
else if ((cl_mode == CL_CHECKFILES) || (cl_mode == CL_ASKFULLFILELIST))
{
INT32 totalfileslength;
INT32 checkcompletednum = 0;
INT32 i;
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_YELLOWMAP, "Press ESC to abort");
//ima just count files here
if (fileneeded)
{
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status != FS_NOTCHECKED)
checkcompletednum++;
}
// Check progress
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_YELLOWMAP, "Checking server addon list...");
totalfileslength = (INT32)((checkcompletednum/(double)(fileneedednum)) * 256);
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, 256, 8, 111);
V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-16, totalfileslength, 8, 96);
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16, V_20TRANS|V_MONOSPACE,
va(" %2u/%2u Files",checkcompletednum,fileneedednum));
}
else if (filedownload.current != -1) else if (filedownload.current != -1)
{ {
char tempname[28]; char tempname[28];
...@@ -224,7 +278,7 @@ static void CL_DrawConnectionStatus(void) ...@@ -224,7 +278,7 @@ static void CL_DrawConnectionStatus(void)
const char *download_str = M_GetText("Downloading \"%s\""); const char *download_str = M_GetText("Downloading \"%s\"");
#endif #endif
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_ALLOWLOWERCASE|V_YELLOWMAP, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-46-24, V_ALLOWLOWERCASE|V_YELLOWMAP,
va(download_str, tempname)); va(download_str, tempname));
// Rusty: actually lets do this instead // Rusty: actually lets do this instead
...@@ -244,16 +298,18 @@ static void CL_DrawConnectionStatus(void) ...@@ -244,16 +298,18 @@ static void CL_DrawConnectionStatus(void)
strlcpy(tempname, http_source, sizeof(tempname)); strlcpy(tempname, http_source, sizeof(tempname));
} }
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_ALLOWLOWERCASE|V_YELLOWMAP, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-46-16, V_ALLOWLOWERCASE|V_YELLOWMAP,
va(M_GetText("from %s"), tempname)); va(M_GetText("from %s"), tempname));
} }
else else
{ {
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_ALLOWLOWERCASE|V_YELLOWMAP, V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-46-16, V_ALLOWLOWERCASE|V_YELLOWMAP,
M_GetText("from the server")); M_GetText("from the server"));
} }
DrawFileProgress(file, BASEVIDHEIGHT-46);
DrawFileProgress(file, BASEVIDHEIGHT-16); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-14, V_ALLOWLOWERCASE|V_YELLOWMAP, "Total Progress");
DrawOverallProgress(BASEVIDHEIGHT-16);
} }
else else
{ {
...@@ -657,6 +713,7 @@ static void ShowDownloadConsentMessage(void) ...@@ -657,6 +713,7 @@ static void ShowDownloadConsentMessage(void)
if (IsFileDownloadable(&fileneeded[i])) if (IsFileDownloadable(&fileneeded[i]))
totalsize += fileneeded[i].totalsize; totalsize += fileneeded[i].totalsize;
} }
filedownload.totalsize = totalsize;
const char *downloadsize = GetPrintableFileSize(totalsize); const char *downloadsize = GetPrintableFileSize(totalsize);
...@@ -1214,7 +1271,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic ...@@ -1214,7 +1271,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
void CL_ConnectToServer(void) void CL_ConnectToServer(void)
{ {
INT32 pnumnodes, nodewaited = doomcom->numnodes, i; INT32 pnumnodes, nodewaited = numnetnodes, i;
tic_t oldtic; tic_t oldtic;
tic_t asksent; tic_t asksent;
char tmpsave[256]; char tmpsave[256];
...@@ -1240,7 +1297,7 @@ void CL_ConnectToServer(void) ...@@ -1240,7 +1297,7 @@ void CL_ConnectToServer(void)
if (gamestate == GS_INTERMISSION) if (gamestate == GS_INTERMISSION)
Y_EndIntermission(); // clean up intermission graphics etc Y_EndIntermission(); // clean up intermission graphics etc
DEBFILE(va("waiting %d nodes\n", doomcom->numnodes)); DEBFILE(va("waiting %d nodes\n", numnetnodes));
G_SetGamestate(GS_WAITINGPLAYERS); G_SetGamestate(GS_WAITINGPLAYERS);
wipegamestate = GS_WAITINGPLAYERS; wipegamestate = GS_WAITINGPLAYERS;
...@@ -1401,7 +1458,7 @@ void PT_ServerCFG(SINT8 node) ...@@ -1401,7 +1458,7 @@ void PT_ServerCFG(SINT8 node)
netnodes[(UINT8)servernode].ingame = true; netnodes[(UINT8)servernode].ingame = true;
serverplayer = netbuffer->u.servercfg.serverplayer; serverplayer = netbuffer->u.servercfg.serverplayer;
doomcom->numslots = SHORT(netbuffer->u.servercfg.totalslotnum); numslots = SHORT(netbuffer->u.servercfg.totalslotnum);
mynode = netbuffer->u.servercfg.clientnode; mynode = netbuffer->u.servercfg.clientnode;
if (serverplayer >= 0) if (serverplayer >= 0)
playernode[(UINT8)serverplayer] = servernode; playernode[(UINT8)serverplayer] = servernode;
......
...@@ -149,8 +149,8 @@ void CL_Reset(void) ...@@ -149,8 +149,8 @@ void CL_Reset(void)
multiplayer = false; multiplayer = false;
servernode = 0; servernode = 0;
server = true; server = true;
doomcom->numnodes = 1; numnetnodes = 1;
doomcom->numslots = 1; numslots = 1;
SV_StopServer(); SV_StopServer();
SV_ResetServer(); SV_ResetServer();
...@@ -215,8 +215,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) ...@@ -215,8 +215,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
CL_ClearPlayer(newplayernum); CL_ClearPlayer(newplayernum);
playeringame[newplayernum] = true; playeringame[newplayernum] = true;
G_AddPlayer(newplayernum); G_AddPlayer(newplayernum);
if (newplayernum+1 > doomcom->numslots) if (newplayernum+1 > numslots)
doomcom->numslots = (INT16)(newplayernum+1); numslots = (INT16)(newplayernum+1);
if (server && I_GetNodeAddress) if (server && I_GetNodeAddress)
{ {
...@@ -612,8 +612,8 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) ...@@ -612,8 +612,8 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
// remove avatar of player // remove avatar of player
playeringame[playernum] = false; playeringame[playernum] = false;
while (!playeringame[doomcom->numslots-1] && doomcom->numslots > 1) while (!playeringame[numslots-1] && numslots > 1)
doomcom->numslots--; numslots--;
// Reset the name // Reset the name
sprintf(player_names[playernum], "Player %d", playernum+1); sprintf(player_names[playernum], "Player %d", playernum+1);
...@@ -641,6 +641,7 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) ...@@ -641,6 +641,7 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
void D_QuitNetGame(void) void D_QuitNetGame(void)
{ {
mousegrabbedbylua = true; mousegrabbedbylua = true;
textinputmodeenabledbylua = false;
I_UpdateMouseGrab(); I_UpdateMouseGrab();
if (!netgame || !netbuffer) if (!netgame || !netbuffer)
...@@ -754,7 +755,7 @@ void SV_ResetServer(void) ...@@ -754,7 +755,7 @@ void SV_ResetServer(void)
if (server) if (server)
servernode = 0; servernode = 0;
doomcom->numslots = 0; numslots = 0;
// clear server_context // clear server_context
memset(server_context, '-', 8); memset(server_context, '-', 8);
...@@ -806,7 +807,7 @@ void SV_SpawnServer(void) ...@@ -806,7 +807,7 @@ void SV_SpawnServer(void)
// non dedicated server just connect to itself // non dedicated server just connect to itself
if (!dedicated) if (!dedicated)
CL_ConnectToServer(); CL_ConnectToServer();
else doomcom->numslots = 1; else numslots = 1;
} }
} }
......
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
#define FORCECLOSE 0x8000 #define FORCECLOSE 0x8000
tic_t connectiontimeout = (10*TICRATE); tic_t connectiontimeout = (10*TICRATE);
INT16 numnetnodes;
INT16 numslots;
INT16 extratics;
/// \brief network packet /// \brief network packet
doomcom_t *doomcom = NULL; doomcom_t *doomcom = NULL;
/// \brief network packet data, points inside doomcom /// \brief network packet data, points inside doomcom
...@@ -182,13 +186,9 @@ static node_t nodes[MAXNETNODES]; ...@@ -182,13 +186,9 @@ static node_t nodes[MAXNETNODES];
// 0 if a = n (mod 256) // 0 if a = n (mod 256)
// >0 if a > b (mod 256) // >0 if a > b (mod 256)
// mnemonic: to use it compare to 0: cmpack(a,b)<0 is "a < b" ... // mnemonic: to use it compare to 0: cmpack(a,b)<0 is "a < b" ...
FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b) FUNCMATH static inline INT32 cmpack(UINT8 a, UINT8 b)
{ {
register INT32 d = a - b; return (SINT8)(a - b);
if (d >= 127 || d < -128)
return -d;
return d;
} }
/** Sets freeack to a free acknum and copies the netbuffer in the ackpak table /** Sets freeack to a free acknum and copies the netbuffer in the ackpak table
...@@ -999,8 +999,8 @@ void D_SetDoomcom(void) ...@@ -999,8 +999,8 @@ void D_SetDoomcom(void)
{ {
if (doomcom) return; if (doomcom) return;
doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL); doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL);
doomcom->numslots = doomcom->numnodes = 1; numslots = numnetnodes = 1;
doomcom->extratics = 0; extratics = 0;
} }
// //
...@@ -1046,10 +1046,10 @@ boolean D_CheckNetGame(void) ...@@ -1046,10 +1046,10 @@ boolean D_CheckNetGame(void)
if (M_CheckParm("-extratic")) if (M_CheckParm("-extratic"))
{ {
if (M_IsNextParm()) if (M_IsNextParm())
doomcom->extratics = (INT16)atoi(M_GetNextParm()); extratics = (INT16)atoi(M_GetNextParm());
else else
doomcom->extratics = 1; extratics = 1;
CONS_Printf(M_GetText("Set extratics to %d\n"), doomcom->extratics); CONS_Printf(M_GetText("Set extratics to %d\n"), extratics);
} }
software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH; software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH;
...@@ -1071,8 +1071,8 @@ boolean D_CheckNetGame(void) ...@@ -1071,8 +1071,8 @@ boolean D_CheckNetGame(void)
if (netgame) if (netgame)
multiplayer = true; multiplayer = true;
if (doomcom->numnodes > MAXNETNODES) if (numnetnodes > MAXNETNODES)
I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); I_Error("Too many nodes (%d), max:%d", numnetnodes, MAXNETNODES);
netbuffer = (doomdata_t *)(void *)&doomcom->data; netbuffer = (doomdata_t *)(void *)&doomcom->data;
......
...@@ -129,7 +129,7 @@ boolean waitingforluafilecommand = false; ...@@ -129,7 +129,7 @@ boolean waitingforluafilecommand = false;
char luafiledir[256 + 16] = "luafiles"; char luafiledir[256 + 16] = "luafiles";
// max file size to send to a player (in kilobytes) // max file size to send to a player (in kilobytes)
static CV_PossibleValue_t maxsend_cons_t[] = {{0, "MIN"}, {204800, "MAX"}, {0, NULL}}; static CV_PossibleValue_t maxsend_cons_t[] = {{-1, "MIN"}, {999999999, "MAX"}, {0, NULL}};
consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_cons_t, NULL); consvar_t cv_maxsend = CVAR_INIT ("maxsend", "4096", CV_SAVE|CV_NETVAR, maxsend_cons_t, NULL);
consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); consvar_t cv_noticedownload = CVAR_INIT ("noticedownload", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
...@@ -206,7 +206,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) ...@@ -206,7 +206,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile)
// Store in the upper four bits // Store in the upper four bits
if (!cv_downloading.value) if (!cv_downloading.value)
filestatus += (WILLSEND_NO << 4); // Won't send filestatus += (WILLSEND_NO << 4); // Won't send
else if (wadfiles[i]->filesize <= (UINT32)cv_maxsend.value * 1024) else if (cv_maxsend.value == -1 || wadfiles[i]->filesize <= (UINT32)cv_maxsend.value * 1024)
filestatus += (WILLSEND_YES << 4); // Will send if requested filestatus += (WILLSEND_YES << 4); // Will send if requested
else else
filestatus += (WILLSEND_TOOLARGE << 4); // Won't send, too big filestatus += (WILLSEND_TOOLARGE << 4); // Won't send, too big
...@@ -849,7 +849,7 @@ static boolean AddFileToSendQueue(INT32 node, UINT8 fileid) ...@@ -849,7 +849,7 @@ static boolean AddFileToSendQueue(INT32 node, UINT8 fileid)
strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH); strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH);
// Handle huge file requests (i.e. bigger than cv_maxsend.value KB) // Handle huge file requests (i.e. bigger than cv_maxsend.value KB)
if (wadfiles[wadnum]->filesize > (UINT32)cv_maxsend.value * 1024) if (cv_maxsend.value != -1 && wadfiles[wadnum]->filesize > (UINT32)cv_maxsend.value * 1024)
{ {
// Too big // Too big
// Don't inform client (client sucks, man) // Don't inform client (client sucks, man)
......
...@@ -95,6 +95,7 @@ typedef struct ...@@ -95,6 +95,7 @@ typedef struct
INT32 remaining; INT32 remaining;
INT32 completednum; INT32 completednum;
UINT32 completedsize; UINT32 completedsize;
UINT64 totalsize;
boolean http_failed; boolean http_failed;
boolean http_running; boolean http_running;
......
...@@ -44,15 +44,6 @@ typedef struct ...@@ -44,15 +44,6 @@ typedef struct
/// Number of bytes in doomdata to be sent /// Number of bytes in doomdata to be sent
INT16 datalength; INT16 datalength;
/// Info common to all nodes.
/// Console is always node 0.
INT16 numnodes;
/// Flag: 1 = send a backup tic in every packet.
INT16 extratics;
/// Number of "slots": the highest player number in use plus one.
INT16 numslots;
/// The packet data to be sent. /// The packet data to be sent.
char data[MAXPACKETLENGTH]; char data[MAXPACKETLENGTH];
} ATTRPACK doomcom_t; } ATTRPACK doomcom_t;
...@@ -61,6 +52,18 @@ typedef struct ...@@ -61,6 +52,18 @@ typedef struct
#pragma pack() #pragma pack()
#endif #endif
/** \brief Number of connected nodes.
*/
extern INT16 numnetnodes;
/** \brief Number of "slots": the highest player number in use plus one.
*/
extern INT16 numslots;
/** \brief Flag: 1 = send a backup tic in every packet.
*/
extern INT16 extratics;
extern doomcom_t *doomcom; extern doomcom_t *doomcom;
/** \brief return packet in doomcom struct /** \brief return packet in doomcom struct
......
...@@ -1105,7 +1105,7 @@ static boolean UDP_Socket(void) ...@@ -1105,7 +1105,7 @@ static boolean UDP_Socket(void)
broadcastaddresses = s; broadcastaddresses = s;
doomcom->extratics = 1; // internet is very high ping extratics = 1; // internet is very high ping
return true; return true;
} }
...@@ -1393,18 +1393,18 @@ boolean I_InitTcpNetwork(void) ...@@ -1393,18 +1393,18 @@ boolean I_InitTcpNetwork(void)
// in-game. // in-game.
// Since Boris has implemented join in-game, there is no actual need for specifying a // Since Boris has implemented join in-game, there is no actual need for specifying a
// particular number here. // particular number here.
// FIXME: for dedicated server, numnodes needs to be set to 0 upon start // FIXME: for dedicated server, numnetnodes needs to be set to 0 upon start
if (dedicated) if (dedicated)
doomcom->numnodes = 0; numnetnodes = 0;
/* else if (M_IsNextParm()) /* else if (M_IsNextParm())
doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/ numnetnodes = (INT16)atoi(M_GetNextParm());*/
else else
doomcom->numnodes = 1; numnetnodes = 1;
if (doomcom->numnodes < 0) if (numnetnodes < 0)
doomcom->numnodes = 0; numnetnodes = 0;
if (doomcom->numnodes > MAXNETNODES) if (numnetnodes > MAXNETNODES)
doomcom->numnodes = MAXNETNODES; numnetnodes = MAXNETNODES;
// server // server
servernode = 0; servernode = 0;
......
...@@ -269,10 +269,10 @@ void PT_TextCmd(SINT8 node, INT32 netconsole) ...@@ -269,10 +269,10 @@ void PT_TextCmd(SINT8 node, INT32 netconsole)
} }
// check if tic that we are making isn't too large else we cannot send it :( // check if tic that we are making isn't too large else we cannot send it :(
// doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time // numslots+1 "+1" since numslots can change within this time and sent time
j = software_MAXPACKETLENGTH j = software_MAXPACKETLENGTH
- (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE - (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE
+ (doomcom->numslots+1)*sizeof(ticcmd_t)); + (numslots+1)*sizeof(ticcmd_t));
// search a tic that have enougth space in the ticcmd // search a tic that have enougth space in the ticcmd
while ((textcmd = D_GetExistingTextcmd(tic, netconsole)), while ((textcmd = D_GetExistingTextcmd(tic, netconsole)),
......
...@@ -245,7 +245,7 @@ static boolean SV_SendServerConfig(INT32 node) ...@@ -245,7 +245,7 @@ static boolean SV_SendServerConfig(INT32 node)
netbuffer->packettype = PT_SERVERCFG; netbuffer->packettype = PT_SERVERCFG;
netbuffer->u.servercfg.serverplayer = (UINT8)serverplayer; netbuffer->u.servercfg.serverplayer = (UINT8)serverplayer;
netbuffer->u.servercfg.totalslotnum = (UINT8)(doomcom->numslots); netbuffer->u.servercfg.totalslotnum = (UINT8)numslots;
netbuffer->u.servercfg.gametic = (tic_t)LONG(gametic); netbuffer->u.servercfg.gametic = (tic_t)LONG(gametic);
netbuffer->u.servercfg.clientnode = (UINT8)node; netbuffer->u.servercfg.clientnode = (UINT8)node;
netbuffer->u.servercfg.gamestate = (UINT8)gamestate; netbuffer->u.servercfg.gamestate = (UINT8)gamestate;
......
...@@ -244,7 +244,7 @@ void PT_ServerTics(SINT8 node, INT32 netconsole) ...@@ -244,7 +244,7 @@ void PT_ServerTics(SINT8 node, INT32 netconsole)
if (realstart <= neededtic && realend > neededtic) if (realstart <= neededtic && realend > neededtic)
{ {
UINT8 *pak = (UINT8 *)&packet->cmds; UINT8 *pak = (UINT8 *)&packet->cmds;
UINT8 *txtpak = (UINT8 *)&packet->cmds[packet->numslots * packet->numtics]; UINT8 *txtpak = (UINT8 *)&packet->cmds[numslots * packet->numtics];
for (tic_t i = realstart; i < realend; i++) for (tic_t i = realstart; i < realend; i++)
{ {
...@@ -253,7 +253,7 @@ void PT_ServerTics(SINT8 node, INT32 netconsole) ...@@ -253,7 +253,7 @@ void PT_ServerTics(SINT8 node, INT32 netconsole)
// copy the tics // copy the tics
pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak, pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak,
packet->numslots*sizeof (ticcmd_t)); numslots*sizeof (ticcmd_t));
CL_CopyNetCommandsFromServerPacket(i, &txtpak); CL_CopyNetCommandsFromServerPacket(i, &txtpak);
} }
...@@ -320,7 +320,7 @@ static tic_t SV_CalculateNumTicsForPacket(SINT8 nodenum, tic_t firsttic, tic_t l ...@@ -320,7 +320,7 @@ static tic_t SV_CalculateNumTicsForPacket(SINT8 nodenum, tic_t firsttic, tic_t l
for (tic_t tic = firsttic; tic < lasttic; tic++) for (tic_t tic = firsttic; tic < lasttic; tic++)
{ {
size += sizeof (ticcmd_t) * doomcom->numslots; size += sizeof (ticcmd_t) * numslots;
size += TotalTextCmdPerTic(tic); size += TotalTextCmdPerTic(tic);
if (size > software_MAXPACKETLENGTH) if (size > software_MAXPACKETLENGTH)
...@@ -337,7 +337,7 @@ static tic_t SV_CalculateNumTicsForPacket(SINT8 nodenum, tic_t firsttic, tic_t l ...@@ -337,7 +337,7 @@ static tic_t SV_CalculateNumTicsForPacket(SINT8 nodenum, tic_t firsttic, tic_t l
if (size > MAXPACKETLENGTH) if (size > MAXPACKETLENGTH)
I_Error("Too many players: can't send %s data for %d players to node %d\n" I_Error("Too many players: can't send %s data for %d players to node %d\n"
"Well sorry nobody is perfect....\n", "Well sorry nobody is perfect....\n",
sizeu1(size), doomcom->numslots, nodenum); sizeu1(size), numslots, nodenum);
else else
{ {
lasttic++; // send it anyway! lasttic++; // send it anyway!
...@@ -394,20 +394,20 @@ void SV_SendTics(void) ...@@ -394,20 +394,20 @@ void SV_SendTics(void)
netbuffer->packettype = PT_SERVERTICS; netbuffer->packettype = PT_SERVERTICS;
netbuffer->u.serverpak.starttic = realfirsttic; netbuffer->u.serverpak.starttic = realfirsttic;
netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic); netbuffer->u.serverpak.numtics = (UINT8)(lasttictosend - realfirsttic);
netbuffer->u.serverpak.numslots = (UINT8)SHORT(doomcom->numslots); netbuffer->u.serverpak.numslots = (UINT8)SHORT(numslots);
// Fill and send the packet // Fill and send the packet
UINT8 *bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds; UINT8 *bufpos = (UINT8 *)&netbuffer->u.serverpak.cmds;
for (tic_t i = realfirsttic; i < lasttictosend; i++) for (tic_t i = realfirsttic; i < lasttictosend; i++)
bufpos = G_DcpyTiccmd(bufpos, netcmds[i%BACKUPTICS], doomcom->numslots * sizeof (ticcmd_t)); bufpos = G_DcpyTiccmd(bufpos, netcmds[i%BACKUPTICS], numslots * sizeof (ticcmd_t));
for (tic_t i = realfirsttic; i < lasttictosend; i++) for (tic_t i = realfirsttic; i < lasttictosend; i++)
SV_WriteNetCommandsForTic(i, &bufpos); SV_WriteNetCommandsForTic(i, &bufpos);
size_t packsize = bufpos - (UINT8 *)&(netbuffer->u); size_t packsize = bufpos - (UINT8 *)&(netbuffer->u);
HSendPacket(n, false, 0, packsize); HSendPacket(n, false, 0, packsize);
// When tics are too large, only one tic is sent so don't go backwards! // When tics are too large, only one tic is sent so don't go backwards!
if (lasttictosend-doomcom->extratics > realfirsttic) if (lasttictosend-extratics > realfirsttic)
node->supposedtic = lasttictosend-doomcom->extratics; node->supposedtic = lasttictosend-extratics;
else else
node->supposedtic = lasttictosend; node->supposedtic = lasttictosend;
node->supposedtic = max(node->supposedtic, node->tic); node->supposedtic = max(node->supposedtic, node->tic);
......
...@@ -6109,7 +6109,7 @@ void A_UnidusBall(mobj_t *actor) ...@@ -6109,7 +6109,7 @@ void A_UnidusBall(mobj_t *actor)
else if (locvar1 == 2) else if (locvar1 == 2)
{ {
boolean skull = (actor->target->flags2 & MF2_SKULLFLY) == MF2_SKULLFLY; boolean skull = (actor->target->flags2 & MF2_SKULLFLY) == MF2_SKULLFLY;
if (actor->target->state == &states[actor->target->info->painstate]) if (P_IsMobjInPainState(actor->target))
{ {
P_KillMobj(actor, NULL, NULL, 0); P_KillMobj(actor, NULL, NULL, 0);
return; return;
......
...@@ -412,7 +412,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) ...@@ -412,7 +412,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{ {
if (special->type == MT_STEAM) if (special->type == MT_STEAM)
{ {
if (player && player->mo->state == &states[player->mo->info->painstate]) // can't use gas jets when player is in pain! if (player && P_IsPlayerInState(player, S_PLAY_PAIN)) // can't use gas jets when player is in pain!
return; return;
fixed_t speed = special->info->mass; // gas jets use this for the vertical thrust fixed_t speed = special->info->mass; // gas jets use this for the vertical thrust
...@@ -1820,7 +1820,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) ...@@ -1820,7 +1820,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (!player->climbing) if (!player->climbing)
{ {
if (player->bot && player->bot != BOT_MPAI && toucher->state-states != S_PLAY_GASP) if (player->bot && player->bot != BOT_MPAI && !P_IsPlayerInState(player, S_PLAY_GASP))
S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots
P_SetMobjState(toucher, S_PLAY_GASP); P_SetMobjState(toucher, S_PLAY_GASP);
P_ResetPlayer(player); P_ResetPlayer(player);
...@@ -1839,8 +1839,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) ...@@ -1839,8 +1839,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
special->z = toucher->z+toucher->height-FixedMul(8*FRACUNIT, special->scale); special->z = toucher->z+toucher->height-FixedMul(8*FRACUNIT, special->scale);
special->momz = 0; special->momz = 0;
special->flags |= MF_NOGRAVITY; special->flags |= MF_NOGRAVITY;
P_SetMobjState (special, special->info->deathstate); P_SetMobjState(special, special->info->deathstate);
S_StartSound (special, special->info->deathsound+(P_RandomKey(special->info->mass))); S_StartSound(special, special->info->deathsound+(P_RandomKey(special->info->mass)));
} }
return; return;
...@@ -3226,8 +3226,8 @@ static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, IN ...@@ -3226,8 +3226,8 @@ static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, IN
return false; return false;
// Ignore IT players shooting each other, unless friendlyfire is on. // Ignore IT players shooting each other, unless friendlyfire is on.
if ((player->pflags & PF_TAGIT && !((cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE) || (damagetype & DMG_CANHURTSELF)) && if ((player->pflags & PF_TAGIT && source && source->player && !(((cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) || ((damagetype & DMG_CANHURTSELF) && source->player == player)) &&
source && source->player && source->player->pflags & PF_TAGIT))) source->player->pflags & PF_TAGIT)))
{ {
if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK))
{ {
...@@ -3242,7 +3242,8 @@ static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, IN ...@@ -3242,7 +3242,8 @@ static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, IN
// Don't allow players on the same team to hurt one another, // Don't allow players on the same team to hurt one another,
// unless cv_friendlyfire is on. // unless cv_friendlyfire is on.
if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE) || (damagetype & DMG_CANHURTSELF)) && (player->pflags & PF_TAGIT) == (source->player->pflags & PF_TAGIT)) if (source && source->player && !((cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) || ((damagetype & DMG_CANHURTSELF) && source->player == player)) &&
(player->pflags & PF_TAGIT) == (source->player->pflags & PF_TAGIT))
{ {
if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK))
{ {
...@@ -3344,7 +3345,7 @@ static boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj_t *sou ...@@ -3344,7 +3345,7 @@ static boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj_t *sou
// Tag handling // Tag handling
if (G_TagGametype()) if (G_TagGametype())
return P_TagDamage(target, inflictor, source, damage, damagetype); return P_TagDamage(target, inflictor, source, damage, damagetype);
else if (damagetype & DMG_CANHURTSELF) else if ((damagetype & DMG_CANHURTSELF) && source && source->player && source->player == player)
return true; return true;
else if (G_GametypeHasTeams()) // CTF + Team Match else if (G_GametypeHasTeams()) // CTF + Team Match
{ {
...@@ -3413,18 +3414,20 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) ...@@ -3413,18 +3414,20 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage)
if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)))
{ {
P_PlayerFlagBurst(player, false); P_PlayerFlagBurst(player, false);
if (source && source->player) if (source && source->player && source->player != player) // Don't score points against yourself
{ {
// Award no points when players shoot each other when cv_friendlyfire is on. // Award no points when players shoot each other when cv_friendlyfire is on.
if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo))
P_AddPlayerScore(source->player, 25); P_AddPlayerScore(source->player, 25);
} }
} }
if (source && source->player && !player->powers[pw_super]) //don't score points against super players if (source && source->player && source->player != player && !player->powers[pw_super]) //don't score points against super players or yourself
{ {
// Award no points when players shoot each other when cv_friendlyfire is on. // Award no points when players shoot each other when cv_friendlyfire is on.
if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo))
{
P_AddPlayerScore(source->player, 100); P_AddPlayerScore(source->player, 100);
}
} }
// If the player was super, tell them he/she ain't so super nomore. // If the player was super, tell them he/she ain't so super nomore.
...@@ -3538,14 +3541,14 @@ static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, ...@@ -3538,14 +3541,14 @@ static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source,
if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)))
{ {
P_PlayerFlagBurst(player, false); P_PlayerFlagBurst(player, false);
if (source && source->player) if (source && source->player && source->player != player) // Don't score points against yourself
{ {
// Award no points when players shoot each other when cv_friendlyfire is on. // Award no points when players shoot each other when cv_friendlyfire is on.
if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo))
P_AddPlayerScore(source->player, 25); P_AddPlayerScore(source->player, 25);
} }
} }
if (source && source->player && !player->powers[pw_super]) //don't score points against super players if (source && source->player && source->player != player && !player->powers[pw_super]) //don't score points against super players or yourself
{ {
// Award no points when players shoot each other when cv_friendlyfire is on. // Award no points when players shoot each other when cv_friendlyfire is on.
if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo))
...@@ -3562,7 +3565,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN ...@@ -3562,7 +3565,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN
if (damagetype == DMG_SPIKE) // spikes if (damagetype == DMG_SPIKE) // spikes
S_StartSound(player->mo, sfx_spkdth); S_StartSound(player->mo, sfx_spkdth);
if (source && source->player && !player->powers[pw_super]) //don't score points against super players if (source && source->player && source->player != player && !player->powers[pw_super]) //don't score points against super players
{ {
// Award no points when players shoot each other when cv_friendlyfire is on. // Award no points when players shoot each other when cv_friendlyfire is on.
if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo))
...@@ -3572,7 +3575,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN ...@@ -3572,7 +3575,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN
if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)))
{ {
P_PlayerFlagBurst(player, false); P_PlayerFlagBurst(player, false);
if (source && source->player) if (source && source->player && source->player != player) // Don't score points against yourself
{ {
// Award no points when players shoot each other when cv_friendlyfire is on. // Award no points when players shoot each other when cv_friendlyfire is on.
if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo))
...@@ -3885,7 +3888,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da ...@@ -3885,7 +3888,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
// To reduce griefing potential, don't allow players to be killed // To reduce griefing potential, don't allow players to be killed
// by friendly fire. Spilling their rings and other items is enough. // by friendly fire. Spilling their rings and other items is enough.
else if (!force && G_GametypeHasTeams() else if (!force && G_GametypeHasTeams()
&& source && source->player && (source->player->ctfteam == player->ctfteam) && source && source->player && source->player != player && (source->player->ctfteam == player->ctfteam)
&& (cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE))) && (cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)))
{ {
damage = 0; damage = 0;
......