I've done a small bit of engine hacking and I'll make sure to add here anything that I come up with that is actually useful. While I have actually written more than one function, at the moment, I've only added one of them here since, for the others, I found natives that perform similar functions. Always read the docs, folks!
Any file updates here have been done on the current 1.2-0 source available at the GitHub respository. Files are referenced from the top level of that source.
For any updates, if interested, update the version numbers in CMakeLists.txt
Once updates are done to the source files, I would recommend deleting all of build and restarting the build from scratch
I'll get around someday to changing this to a patch file but I pulled this from my notes so it is what it is for now
connected()
This function is similar to the MOO function connected_players(). When you can almost put these anywhere,
I usually added the definition somewhere near the definition for "connection".
- src/grammar.y: around line 143, add "F_CONNECTED" on one of the "%token" lines
- src/opcodes.c: around line 152, add "{ F_CONNECTED, "connected", func_connected },"
- src/ops/network.c: around line 16, add "extern Conn * connections;"
- src/ops/network.c: add to the end of the file these lines
COLDC_FUNC(connected) { cList * info; cData d; Conn * conn; if (!func_init_0()) return; info = list_new(0); d.type = OBJNUM; write_err("entering loop"); for (conn = connections; conn; conn = conn->next) { if (!conn->flags.dead) { write_err("passing through loop"); d.u.objnum = conn->objnum; info = list_add(info,&d); } } write_err("exiting loop"); push_list(info); list_discard(info); }
- src/io.c: line 21, change "static Conn * connections;" to "Conn * connections;"
- src/include/functions.h: add "COLDC_FUNC(connected);"