Commit graph

74 commits

Author SHA1 Message Date
Alug
d2c9a3e1b6 BLUA: simplify lua number hash 2026-04-27 17:17:06 -04:00
yamamama
b876e585b1 Don't optimize out getstack, please! 2026-04-19 09:40:25 -04:00
Alug
5d200154e8 lua_pushlstring: prefer luaS_newlstr over luaS_new
the latter calls strlen which is not needed as the empty string has no length
2026-02-28 08:06:20 -05:00
NepDisk
d62c23f134 Revert "Experiment: replace lua´s string hash with luajits ARX hash"
This reverts commit b0cf9cdc18.
2026-02-28 08:06:20 -05:00
NepDisk
b04bfe08a7 Revert "blua: handle 0 length strings in hash_sparse"
This reverts commit c582767603.
2026-02-28 08:06:20 -05:00
NepDisk
ecd29f9668 Revert "luaS_newlstr: use hash also for checking strings"
This reverts commit ead56b83e3.
2026-02-28 08:06:20 -05:00
NepDisk
d447c793a9 Revert "lua_pushlstring: prefer luaS_newlstr over luaS_new"
This reverts commit 80db0bde07.
2026-02-28 08:06:20 -05:00
NepDisk
208d1d1b3e Revert "hash_sparse: change length checks"
This reverts commit b0da7ac519.
2026-02-28 08:06:20 -05:00
NepDisk
8aa512e2a4 Revert "blua: attempt emergency garbo collection on file io operations if they fail"
This reverts commit c3ee45e6fa.
2026-02-25 08:20:07 -05:00
Alug
b0da7ac519 hash_sparse: change length checks
dont early return on 0 len, let it be the falltrough case, this seems to help branch prediction
2026-02-24 12:47:33 -05:00
Alug
80db0bde07 lua_pushlstring: prefer luaS_newlstr over luaS_new
the latter calls strlen which is not needed as the empty string has no length
2026-02-24 12:22:18 -05:00
Alug
c3ee45e6fa blua: attempt emergency garbo collection on file io operations if they fail
ports of
e885dee5ab

and

3d838f635c

prevents massive memory leaks and other issues due to faulty lua scripts
2026-02-22 17:05:53 -05:00
Indev
d0f0744dcf Push empty string instead of null if len == 0 in lua_pushlstring 2026-02-22 16:29:00 -05:00
Roberto Ierusalimschy
14122c3098 Avoid computing invalid addresses
luaV_execute should compute 'ra' only when the instruction uses it.
Computing an illegal address is undefined behavior even if the address
is never dereferenced.
2026-02-22 16:23:07 -05:00
Alug
ead56b83e3 luaS_newlstr: use hash also for checking strings
taken from raptorjit
we can check the hash first to skip quite a bunch of memcmps which should be faster in most cases (hopefully but quick timedemo tests confirmed that)
2026-02-22 15:20:51 -05:00
Alug
c582767603 blua: handle 0 length strings in hash_sparse 2026-02-22 15:20:41 -05:00
Alug
b0cf9cdc18 Experiment: replace lua´s string hash with luajits ARX hash
the string hashing was the most hit and most spent in part of the whole game in alot of cases
replacing it with luajits algo absolutely massively improves lua performance (10-15fps in my bench timedemos!)
however idk how all this stuff exactly works so this needs alot of testing to make sure nothing breaks
ive rewritten the unaligned ptr access slightly to use memcpy for safety with some platforms that require stricter alignment
2026-02-22 15:20:29 -05:00
NepDisk
277131a5a3 Rename SRB2SDL to BLANKART 2026-02-11 22:44:28 -05:00
GenericHeroGuy
c91eaa5e0b Make compatmode writable, fix compatmode in nested hooks 2026-01-01 21:15:39 +01:00
GenericHeroGuy
a9c66ec217 Set lua_compatmode for console commands and cvar functions
Thanks Indev for finding this oopsie and the patch for command code
2025-12-16 23:23:16 +01:00
NepDisk
6d6cb09280 Convert most strcmp/stricmp to fastcmp/fasticmp 2025-12-11 13:00:32 -05:00
NepDisk
f1db68a167 Send Makefile build to the shadow zone
Theres no way I'm fixing those now lmao, too tied to CPM at this point
2025-11-17 14:34:13 -05:00
GenericHeroGuy
4530947eaf Spare some external libraries from the MSVC purge 2025-10-17 18:02:13 +02:00
NepDisk
0450f45635 Kill MSVC
We are a GCC and Clang household, get this shit outta here
2025-10-16 20:42:11 -04:00
Gustaf Alhäll
9986f9aaef Fix OS-specific behavior caused by integer overflow on Lua numbers 2025-09-07 11:50:10 -04:00
NepDisk
f004b36dbb Revert 'Merge pull request 'File loading refactor' (#68) from wadstrbuf into blankart-dev'
This reverts commit f72475b557, reversing
changes made to 0c89c85aae.

Sorry Generic this branch is really cool but it needs more work. I shouldn't have merged it too early...
2025-06-30 01:45:01 -04:00
GenericHeroGuy
92c59ddbcb Merge branch 'blankart-dev' into wadstrbuf 2025-06-27 18:46:47 +02:00
GenericHeroGuy
7aae6775e6 Use LUMPERROR instead of INT16_MAX, and MAX_WADFILES instead of UINT16_MAX
The 32768th lump of a file works now lol
2025-06-25 17:47:57 +02:00
Sky Dusk
ffde1365a5 Remove format whitelist for read only Lua IO and allow more formats. 2025-06-24 12:15:20 -04:00
NepDisk
760a8574c2 Toss some backcompat lua shit under lua_compatmode 2025-02-04 07:54:32 -05:00
NepDisk
5ed31109fe Use io local if theres no callback. 2024-12-31 11:18:28 -05:00
NepDisk
ec7e1e7f2c Go back to using Sourcefiles since make works again. 2024-10-22 16:56:19 -04:00
Sal
f0370fc1a1 Merge branch 'cmake-sources' into 'master'
Move sources list from Sourcefile to CMakeLists.txt

See merge request KartKrew/Kart!795
2024-10-15 04:36:26 -04:00
NepDisk
914a4fa9e1 Remove dumb artifical restriction.
Yes I know this is for safety but it makes file io really really annoying
2024-10-07 21:58:07 -04:00
James R
e1d642f751 Hardcode assist, part J (jartha)
- Add read-only `actionname` field to Lua states.
    - Resolves to function name definition of global Lua functions.
    - Resolves to all-uppercase name for C actions.
    - Resolves to "NULL" string if nil.
2024-08-21 16:49:29 -04:00
LJ Sonic
496fd82962 Expose debug library to Lua 2024-08-01 01:47:02 -04:00
Sally Coolatta
bdf8ce3064 Paired down OS Lua library
Pretty much removed everything except for time operations. File operations steps on the toes of the IO library, and the others were useless or invasive. The only one I wasn't sure about was `os.tmpname()`, but I think that's something that could be implemented for IO library instead if necessary.

The main reason I want this is because os.time provides an OK way to initially seed RNG on game first boot. But it would also be cute to let Lua modders be able to re-implement Christmas mode / day&night cycles themselves :p
2024-08-01 00:07:17 -04:00
Roberto Ierusalimschy
199c40a14d useless test removed (pointed by lint) 2022-05-11 12:17:49 -07:00
James R
d5c08ac034 Backport 2021 SRB2 makefile overhaul
This is a squashed commit of the following commits from
upstream:

James R <justsomejames2@gmail.com> on 2021-05-01
Commit 44d217807f71d15bd7ca69dad226458e7060ccab
> Collect makefiles

James R <justsomejames2@gmail.com> on 2021-05-04
Commit f637e28d0c1877c44acd7b01f7130625d5ea4099
> Remove bin, objs and dep directories

James R <justsomejames2@gmail.com> on 2021-05-02
Commit b31056c7d977fe3c2a5e0637589fd9521f1f6c04
> Rewrite Makefile to be modular as well as more automated
>
> Some key points for programmers:
> - Source code files are mostly listed in a 'Sourcefile'.
>   So you no longer directly edit the object list. There
>   can be multiple Sourcefiles and they can even live in
>   subdirectories--the directory name will be prepended to
>   every filename in the list. Of course, the Makefile
>   still needs to be edited to read from each Sourcefile.
> - Different rules are no longer required for source code
>   files that live in subdirectories (such as sdl/ or
>   hardware/). Subdirectories Just Work so go ham!
>
> In addition to those points, another important change is
> that the bin directory is no longer divided into platform
> subdirectories (Linux64, Mingw, etc). Executables now go
> directly into bin. If you use DEBUGMODE or target 64-bit,
> then subdirectories for 'debug' and '64' will be made
> though.
>
> Oh by the way, I don't think make clean actually removed
> files before on Windows. It should now. I also fixed as
> many little inconsistencies like that as I noticed.
>
> And now just an overview of the technical aspects that
> shouldn't affect anyone who doesn't REALLY care about the
> Makefile...
>
> objs and dep directories have been moved to a make
> directory. Makefile.cfg and its variants have been moved
> out of their various subdirectories to src/Makefile.d
> make distclean removes the bin and make directories
> entirely, but make clean and cleandep still only affect
> the current build target.
>
> When I say automation, I mean that a lot of copy pasting
> in the Makefile has been reduced.

James R <justsomejames2@gmail.com> on 2021-05-04
Commit 53d1cbe8264196e46911c86bc4be13d44aa35dfe
> Appveyor: update executable directory

James R <justsomejames2@gmail.com> on 2021-05-04
Commit 888073d64d1885cae0ad8b5d54bfec31e9793e0a
> Fix make clean printing header

James R <justsomejames2@gmail.com> on 2021-05-04
Commit 3d7205d4942d1e1b2627fdf5acf9d9c82437a97b
> Fix minor errors with Windows ECHO, DEL, MD
>
> - Quotes were not removed by ECHO.
> - DEL would print an error on nonexistent file.
> - MD would do this plus return a nonzero exit code.

James R <justsomejames2@gmail.com> on 2021-05-05
Commit f9813844e7f0dfa6229062b1ebd83e4e8150c120
> Update CMakeLists.txt to use Sourcefiles
>
> This establishes (near) parity of source code file lists
> between the Makefile and CMakeLists.txt
>
> To make that change I messed around CMakeLists.txt a bit.
> It now uses target_sources and target_compile_definitions.
> I also removed some MSVC stuff since we don't actually
> care about MSVC--it made things easier.
>
> CMake minimum version 3.0 -> 3.13 for target_sources.

James R <justsomejames2@gmail.com> on 2021-05-05
Commit ec8b63d6759f0c124693ea6d5a521e8d82efd566
> Makefile: remove last of unused flags

James R <justsomejames2@gmail.com> on 2021-05-07
Commit c06817d0085ee77b0027917bca91a24e60c7deba
> Makefile: fix mingw/64 swapped with 32-bit

James R <justsomejames2@gmail.com> on 2021-05-07
Commit 9e7d80c2c44199126fa451c59fca0f98d23ad14d
> Makefile: suppress DEL error

James R <justsomejames2@gmail.com> on 2021-05-07
Commit 87afa7655a71539c7cbc7db12df18c4253187fbc
> CMake: fix ASM compile
>
> - target_sources from correct directory
> - enable_language must be used in add_executable directory

James R <justsomejames2@gmail.com> on 2021-05-08
Commit 210c9419e4bddd1fe8e9be7cb66de31119fa0d68
> Ignore -Wtrigraphs

James R <justsomejames2@gmail.com> on 2021-06-16
Commit 3a044e71cc7cf6c80d9836189511c1a58c108370
> Disable EXE disassembly and compression by default
>
> NOOBJDUMP=1 and NOUPX=1 have been removed. Make 'dump'
> target to disassemble. UPX=upx to compress executable.
>
> Setting UPX used to cause it to fail. That has been fixed.

James R <justsomejames2@gmail.com> on 2021-06-16
Commit c142b3241ddb8f1ea9b5090d20dffa43a17129ab
> Makefile: alert full path of final executable
>
> With added textual contrast.

James R <justsomejames2@gmail.com> on 2021-06-16
Commit b04c79d8a7ba4ae8f888ab94d394b6714699e107
> Say 'at'

James R <justsomejames2@gmail.com> on 2021-06-21
Commit 2d7a8c3c571bcc5335437e9db074c75af00408ce
> Makefile: use shell commands to read in Sourcefile
>
> File function is not supported < Make 4.2.

James R <justsomejames2@gmail.com> on 2021-06-21
Commit d5146945a69ebf30e6fc1fbb64558e456e0b7459
> Makefile: don't automatically set WINDOWSHELL unless PATH matches Windows norms
>
> This is for MSYS2, which requires unix shell commands.

James R <justsomejames2@gmail.com> on 2021-06-22
Commit 5f4d7e3c5b013afe03ae2a441c82ad79bae7c66c
> Makefile: fail if old build directories exist
>
> After a checkout from before revision, old directories
> such as bin/Linux64 only remain if untracked files exist
> within. This may be confusing to the user. They may even
> use an outdated executable if it is one of those untracked
> files.

James R <justsomejames2@gmail.com> on 2021-06-22
Commit c3ad5de912fccfdd64c510f5684883afceaa7d36
> Makefile: let variables be defined on Make line
>
> If a variable is defined as in 'make CC=gcc-10', then that
> definition overrides anything other definition in the
> Makefile.

James R <justsomejames2@gmail.com> on 2021-06-22
Commit ed85e994a46ace07cf022b38a9abac1698a8667e
> Remove misplaced parentheses

James R <justsomejames2@gmail.com> on 2021-06-29
Commit c1ecfa306f6a0b168d4f6cbc3224ebebd4deec51
> Makefile: 'dep' not 'deps'

James R <justsomejames2@gmail.com> on 2021-06-29
Commit 6c03f9b5b3590e01773f05bc1c31cc67a2d88fc2
> fuck

James R <justsomejames2@gmail.com> on 2021-06-29
Commit abdf5c101cbe80657f210c0b90800e2c4c6f0c05
> Makefile: report SHELL

James R <justsomejames2@gmail.com> on 2021-06-29
Commit 22ab611daa17bd23225f3afeeba39147c0d0fe17
> Makefile: do not automatically set WINDOWSHELL
>
> According to this answer--
> https://stackoverflow.com/a/45952425
> --Make will always prefer a unix shell, even on Windows,
> if one can be found in Path. So we can't check PATH to
> determine if it's a Windows shell... this is just too much
> bother.

James R <justsomejames2@gmail.com> on 2021-06-29
Commit f79e0ee540564fcec5da7c0dc4006906492a7f30
> Appveyor: remove 64-bit target

James R <justsomejames2@gmail.com> on 2021-06-29
Commit faee657572f23cd6f8b68c077873e01c4278414e
> Appveyor: update for new Makefile

James R <justsomejames2@gmail.com> on 2021-06-29
Commit 44b82dea58612e6f07830647e2b08555f54a7caa
> Appveyor: remove redundant CFLAGS
>
> Also changed -Wno-error=implicit-fallthrough to
> -Wno-implicit-fallthrough. For some reason Appveyor's
> version of GCC is triggering these warnings despite the
> comments, so just shut it up.

James R <justsomejames2@gmail.com> on 2021-06-29
Commit db919accd22350c087c1fd0e5122d8e490e2f171
> Appveyor: suppress real time file names

James R <justsomejames2@gmail.com> on 2021-07-12
Commit 58fa44e8dc0444eecbe701f31872fad9fa563a6a
> CMP0115

SteelT <steeltitanium1@gmail.com> on 2021-07-16
Commit 71f905f95bd4fe62dbca87208cf71b7309f12de1
> Fix gme support being effectively disabled
>
> I found this easier than trying to adjust the makefile, as it uses the same thing to automatically generate the various NO* compile options.

James R <justsomejames2@gmail.com> on 2021-08-14
Commit 824b1ab28cdddfd1c018454a9af14dabaab49fcd
> Makefile: use full stem in dependency generation
>
> Previously took only the filename, so the directory
> component was stripped. This broke dependencies for
> basically every file.

GoldenTails <milestailsprower101n2@gmail.com> on 2021-08-28
Commit 1a8ec7975c20e1d652cbbdb7a9e366192e41c05f
> Makefile: Improve gcc detection
>
> Wasn't working for me until I fixed it.
> Turns out gcc really doesn't like giving its name out.
> Most of the time it reads argv[0].
2021-11-25 03:56:23 -08:00
Nev3r
9d99a7880e Merge branch 'next' of https://git.do.srb2.org/STJr/SRB2 into lua-tag-iterator
# Conflicts:
#	src/doomtype.h
2020-12-16 17:27:44 +01:00
James R
f1b060f695 Merge branch 'blua-urite' into 'next'
Fix crash when trying to use bitwise NOT on true/false/nil

See merge request STJr/SRB2!1262
2020-12-10 15:03:39 -05:00
James R
775cb46f75 Lua taglib for accessing taggroups
The global "tags" can be iterated upon for every unique tag which is set in the
level. If a tag is set on a sector/line/thing, it will be included. Taking the
length of "tags" will give you the number of these unique tags. (If a tag is
set on multiple sectors/lines/things, it will only be counted once though.)

For sectors, lines and mapthings, call the field "tagged". This function takes
one argument, which is the tag. The return value can be iterated over for all
the sectors/lines/things with that tag. The length can also be taken for the
number of such objects. If no argument is given, the global tag is default.
2020-12-04 00:30:08 -08:00
James R
11060253f8 More concise 2020-11-21 13:43:32 -08:00
James R
3b30cc408f Lua: disallow bitwise not on anything but number values
This fixes a crash.
2020-11-21 13:37:45 -08:00
Louis-Antoine
05ae84bd09 Fix Lua stacktrace not showing in various situations 2020-11-13 19:12:25 +01:00
James R
66a6374dbe Merge branch 'lua-polyobjects' into 'next'
Lua polyobjects

Closes #19

See merge request STJr/SRB2!1140
2020-10-15 19:08:54 -04:00
Steel Titanium
58d4045b93 Make "divide by zero" or "modulo by zero" errors show the file and line of where it happened
Shouldn't break scripts as it stops execution as soon it happens, like it already does.
2020-09-14 22:54:07 -04:00
GoldenTails
92f8fb360e Can we just do this please? Thanks. 2020-09-09 22:19:14 -05:00
Monster Iestyn
d5030f8a02 Begin work on adding access to polyobjects in Lua:
* create new file lua_polyobjlib.c
* made a stub LUA_PolyObjLib function
* added META_POLYOBJ to lua_libs.h
* updated makefile, CMake and MSVC project files for lua_polyobjlib.c
2020-09-08 18:08:08 +01:00
Nev3r
ef7a95e7d7 Merge branch 'dofile' into 'next'
Add dofile() to Lua

See merge request STJr/SRB2!969
2020-06-12 02:32:16 -04:00