Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - QwazyWabbit

Pages: 1 2 3 4 5 6 7 8 9 10 [11] 12 13 14 15 16 17 18 19 20 21 ... 82
151
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 14, 2016, 05:20:15 PM »
Hey all,
I have been granted access to the repository at https://bitbucket.org/jwaggoner/tmg
and after some general learning curve difficulties changing over from my local SVN repository to the git system, I've updated the code there and you can now clone the latest changes. It should all be good in Linux and Windows.

Caution: the VS project files might need tweaking for your local setup, I didn't put the mod in my ctf folder.

If you spot a bug, let me know.

QW

152
0x1337c0de / Re: Unsequenced modification and access to 'n'
« on: May 13, 2016, 09:42:17 PM »
That's very interesting, OS X is based on FreeBSD. The compiler version will have the most influence of course. What version compiler does he have and what version OS?

The convert_string function is in g_utils.c in the TMG mod. You can copy-paste the code from here into your copy. The archive I posted May 7 has the bug, the one I posted May 8 has a version of my replacement and should work correctly.

153
0x1337c0de / Unsequenced modification and access to 'n'
« on: May 12, 2016, 01:28:14 AM »
While hacking TMG mod I found this little gem:

Code: [Select]
// From QDevels, posted by outlaw
void convert_string(char *src, char start, char end, char add, char *dest)
{
    int n = -1;
    while ((dest[++n] = src[n]))
        if ((dest[n] >= start) && (dest[n] <= end) && (dest[n] != '\n'))
            dest[n] += add;
}

/* Examples of convert_string usage
 {
 char  text[] = "abcdefgABCDEFG1234567\n\0";
 convert_string(text, 'a', 'z', ('A'-'a'), text); // a -> A
my_bprintf (PRINT_CHAT, "text = %s\n", text);
 convert_string(text, 'A', 'Z', ('a'-'A'), text); // A -> a
my_bprintf (PRINT_CHAT, "text = %s\n", text);
 convert_string(text, 0, 127, 128, text); // white -> green
my_bprintf (PRINT_CHAT, "text = %s\n", text);
 convert_string(text, 128, 255, -128, text); // green -> white
my_bprintf (PRINT_CHAT, "text = %s\n", text);
 }
 */

What first caught my eye was the warning from the compiler per the subject line but second was the fun and exciting int n = -1; initialization. OK, so we're being really 1337 coder and were starting the index off below the array bounds of dest and the ++n is going to make it 0 before it puts the value of src[n] into the destination.... or does it?

The warning is about that dest[++n] thing. This is a reliance on undefined behavior in C and it can be a nasty bug. It will work fine in one platform and fail in another and it can take some time to fix if it's buried deep enough. As it was, Microsoft Visual Studio 2010 likes it and it works. It also works on Ubuntu and GCC 4.8.4 but it doesn't work on OS X, using clang/LLVM. Since Microsoft is migrating to using clang on their compiler suite you can expect this function will break when compiled on the new tools or in their Azure cloud. It may also fail on newer versions of GCC on other Linux distributions.

OK, so how to fix it? Answer: pointers instead of array indexes.

Code: [Select]
/**
 Replace characters in destination string.
 Parameter 'add' is added to each character found in source and result is placed in dest.
 Parameters 'start' and 'end' specify character range to replace.
 Source text must be a valid C string.
*/
//QwazyWabbit// A pointer version to eliminate undefined behavior.
void convert_string(char *src, char start, char end, char add, char *dest)
{
while ((*dest = *src)) {
if ((*dest >= start) && (*dest <= end) && (*dest != '\n'))
*dest += add;
src++, dest++;
}
}

In keeping with the existing 1337ness of the code, I made good use of the comma operator. :)

If your projects contain this original Qdevels/outlaw function I urge you replace it ASAP. You'll know the old one is broken when your Q2 strings and chats suddenly become blank when you port your mod instead of green or white.

In addition, I offer the following wrapper functions to use in place of the rather complicated direct uses of the 'convert_string' function:

Code: [Select]
/**
 Set msb in specified string characters, copying them to destination.
 Text must be a valid C string.
 Source and destination can be the same.
 If dest == NULL the action occurs in-place.
 */
void highlight_text (char *src, char *dest)
{
if (dest == NULL)
dest = src;
convert_string(src, 0, 127, 128, dest); // white -> green
}

/**
 Clear msb in specified string characters, copying them to destination.
 Text must be a valid C string.
 Source and destination can be the same.
 If dest == NULL the action occurs in-place.
 */
void white_text (char *src, char *dest)
{
if (dest == NULL)
dest = src;
convert_string(src, 128, 255, -128, dest); // green -> white
}

/**
 Make text uppercase.
 Text must be a valid C string.
 Source and destination can be the same.
 If dest == NULL the action occurs in-place.
 */
void toupper_text(char *src, char *dest)
{
if (dest == NULL)
dest = src;
convert_string(src, 'a', 'z', ('A'-'a'), dest); // a -> A
}

/**
 Make text lowercase.
 Text must be a valid C string.
 Source and destination can be the same string.
 If dest == NULL the action occurs in-place.
 */
void tolower_text(char *src, char *dest)
{
if (dest == NULL)
dest = src;
convert_string(src, 'A', 'Z', ('a'-'A'), dest); // A -> a
}


Testbed code:

Code: [Select]
#include <stdio.h>

int main(int argc, const char * argv[])
{
char otext[] = "abcdefgABCDEFG1234567";
char text[]  = "abcdefgABCDEFG1234567\n";
char target[sizeof text];

toupper_text(otext, target); // a -> A
printf ("otext   = %s\n", otext);
printf ("target  = %s\n", target);
toupper_text(text, NULL); // a -> A
printf ("text    = %s\n", text);

tolower_text(otext, target); // A -> a
printf ("otext   = %s\n", otext);
printf ("target  = %s\n", target);
tolower_text(text, NULL); // A -> a
printf ("text    = %s\n", text);

highlight_text(otext, target); // white -> green
printf ("otext   = %s\n", otext);
printf ("target  = %s\n", target);
highlight_text(text, NULL); // white -> green
printf ("text    = %s\n", text);

white_text(target, otext); // green -> white
printf ("target  = %s\n", target);
printf ("otext   = %s\n", otext);
white_text(text, NULL); // green -> white
printf ("text    = %s\n", text);

return 0;
}

154
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 08, 2016, 09:32:05 PM »
You're welcome. I've enjoyed hacking this mod a bit.

Here's another updated zip file.

This version compiles cleanly on Linux, OS X and Windows.
I also fixed the timeleft and GetTime functions that were a little kluged.

The convert_string function contained a dependency on undefined behavior that was spotted by clang on OS X. The function failed on OS X. I don't have a Linux server so I don't know if it was broken in Linux like it was on Mac. I rewrote it so it works properly on all platforms and added some wrapper functions that might be useful.

Fixed some buffer overflows that were glaringly obvious.
Any warnings or errors you get now will be your own. :)

155
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 07, 2016, 11:10:07 PM »
Here's the project as I have it so far. It builds clean in Windows on VS2010 Ultimate (I haven't tested it in VS2015 yet but it should convert easily) and fairly clean in Linux and OS X. I cleaned up some code and removed unused variables and whatnot to satisfy clang and gcc. Some warnings still exist but they're mostly harmless. I tested it all with bots active on Windows and it runs. Linux makefile included, just "make all" to build.

Let me know if you find some bugs. I'm sure they exist. :)

If you have the flags and banners for this mod I'd appreciate it if you could send them along. Does it use the same as other CTF? I haven't investigated this but it looks likely. All I have for red and blue flags are pyramids in R1Q2.

156
Politics / Re: Current Politics & History Only Thread
« on: May 06, 2016, 10:24:58 PM »
The end of the concept of "civil discourse".

Lie
Cheat
Tweet
Rant
Repeat

157
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 06, 2016, 10:22:41 PM »
If you're into programming and you want to be astounded by a truly awesome and insane C function, check out the code here in the TMG mod.

https://bitbucket.org/jwaggoner/tmg/src/58b52f6341fa2e1d6608035eb36e974787a1329c/TMG/bot_za.c?at=master&fileviewer=file-view-default

Scroll down to line 2215 and behold the Bots_Move_NORM function. This single function is 3,649 lines long! It contains 38 GOTO's and it must have been insanely difficult to debug. Normally a C function is no more than 20 or 30 lines long and it performs a single "function" as part of solving a larger problem or set of tasks. Something 100 times larger than that just leaves me shaking my head. FYI, there are 72 goto's in the entire project, 53% of them are in this single function. A superb example of how NOT to write code. The author must be a genius because I can't keep that much code in my head, I like my functions to be a single page on the screen so I can see it all at once and not scroll forever.

 :ubershock:

158
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 05, 2016, 04:30:11 PM »
Here's the makefile. You will get lots of warnings and errors on the source files.
To do a complete rebuild, do this command in the shell:

make all

After the initial rebuild, you can do incremental builds just type make at the command line. The only time you need to "make depends" is if you add/alter include files or *.h, this rebuilds the dependency tree so make knows which .C files to recompile.

I've made lots of changes to my copy of the code but I don't have diffs to post. I run the code through Linux, VS2010 and Xcode (clang) compilers and massage thoroughly. :)

Regarding stricmp and strnicmp:

Place this block in q_shared.h, just below the definition of the NULL pointer in lines 39-41.

Code: [Select]
#ifndef _WIN32
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif



Code: [Select]
#
# Quake2 gamei386.so Makefile for Linux 2.0
#
# Jan '98 by Zoid <zoid@idsoftware.com>
#
# ELF only
#
# Edited May 5, 2016 by QwazyWabbit
#
# Requires GNU make
#

ARCH=i386

# on x64 machines do this preparation:
# sudo apt-get install ia32-libs
# sudo apt-get install libc6-dev-i386
# this will let you build 32-bits on ia64 systems
#

#use these cflags to optimize this build
CFLAGS=-O3 -m32 -march=$(ARCH) -DARCH="$(ARCH)"
#use these when debugging
#CFLAGS=-g -m32 -DARCH="$(ARCH)" -Wall

# flavors of Linux
ifeq ($(shell uname),Linux)
#SVNDEV := -D'SVN_REV="$(shell svnversion -n .)"'
#CFLAGS += $(SVNDEV)
CFLAGS += -DLINUX
LIBTOOL = ldd
endif

# OS X wants to be Linux and FreeBSD too.
ifeq ($(shell uname),Darwin)
#SVNDEV := -D'SVN_REV="$(shell svnversion -n .)"'
#CFLAGS += $(SVNDEV)
CFLAGS += -DLINUX
LIBTOOL = otool
endif

SHLIBEXT=so
#set position independent code
SHLIBCFLAGS=-fPIC

ORIGDIR=Source

DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<

.c.o:
$(DO_SHLIB_CC)

#############################################################################
# SETUP AND BUILD
# GAME
#############################################################################

GAME_OBJS = \
anticheat.o bot.o bot_fire.o bot_func.o bot_za.o camper.o e_hook.o eavy.o filehand.o \
filtering.o g_chase.o g_cmds.o g_combat.o g_ctf.o g_func.o g_items.o g_main.o g_misc.o \
g_monster.o g_phys.o g_save.o g_spawn.o g_svcmds.o g_target.o g_trigger.o g_utils.o \
g_weapon.o gslog.o highscore.o hud.o intro.o locdamage.o m_move.o s_map.o models.o \
p_client.o p_hud.o p_light.o p_menu.o p_trail.o p_view.o p_weapon.o q_shared.o \
runes.o stdlog.o timer.o vote.o

game$(ARCH).$(SHLIBEXT) : $(GAME_OBJS)
$(CC) $(CFLAGS) -shared -o $@ $(GAME_OBJS) -ldl -lm
$(LIBTOOL) -r $@


#############################################################################
# MISC
#############################################################################

clean:
/bin/rm -f $(GAME_OBJS) game$(ARCH).$(SHLIBEXT)

depend:
gcc -MM $(GAME_OBJS:.o=.c)

depends:
$(CC) $(CFLAGS) -MM *.c > dependencies

all:
make clean
make depends
make

-include dependencies


Modified make file to include "make all", this rebuilds the entire project from a Linux command line.

159
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 05, 2016, 02:01:10 AM »
The phrase "Too many maps in rotation" doesn't exist in the source code. I suspect the version you ran that showed that result wasn't built from that source. This source looks newer.

The variable "mapqueue" doesn't appear in this source either. This source is doing something a little different with the maplist. It keeps an array of 128 map names in game and the vote tally for each. I've never seen this before and it looks like it's done for the menues. I'd say right now you're limited to a total of 128 maps.

The source won't compile on Linux as-is. It's strictly Windows until it can be modified.

Examples: stricmp and strnicmp functions don't exist on Linux.

I have the code building clean on Windows but I haven't tried to run it yet.

160
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 05, 2016, 01:33:27 AM »
The bitbucket source is a bit dated and isn't quite ready to compile on modern Linux yet. :) I had to modify the makefile and some other things to make it work... The Visual Studio project is older also. I had to modify it to build in VS2010. I have not tried it in VS2015.

I'll have more in a bit...

161
Quake / Re: New Anticheat Release
« on: May 04, 2016, 09:56:33 PM »
Loads and runs OK on Windows 10 with MSE as only malware protection. Windows Defender doesn't flag it. No false positives from April MRT.

162
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 01, 2016, 12:39:40 AM »
Man, those are some shitty, spammy web sites. I have not been able to set this up yet, I just looked at the zip files.

As far as your maps.lst file goes, yes, some mods never used a maps list file but used a cvar to contain all the map names in their rotation. The result was sometimes a fairly limited rotation but you could change it on the fly but it looks like this mod uses maplist files.

Play this two ways:
1. keep the map list file short, say, 3 maps. Check the startup and rotation.
2. remove the map list file and set the sv_maplist in your config, also keeping it short.

See which method works.

Looking into the TMG archive and binary, the message is clearly from the mod and the argument to the message is a variable but I can't tell what variable it is at this moment. It appears the 25 might be a configurable number.

There are also default paths to map files:
./cfg/maps_ctf.txt
./cfg/maps_dm.txt

It looks like the name of the map list file might be the cvar maplist.

There are *.nav files, 31 of them. Looks like routes for the bots for the named maps.

I'd start with the q2dm1 through q2dm5 rotation to test the startup of the server as they have in the maps_dm.txt file.


163
Quake / Re: APRQ2: Where To Download?
« on: March 19, 2016, 03:41:56 PM »
Jay can answer specifically but most engines and DLL's are built as i386 (32-bit) binaries. There is no reason to build 64-bit versions because there is no advantage to it and more than likely it can actually be detrimental to the engine's performance. This is due to the fact that pointers will be 64-bits and carrying them around in an application that doesn't need a huge chunk of memory confers a bandwidth hit where a cache miss and memory accesses are concerned. Quake 2 doesn't warrant a 64-bit address space and expanding it to use more objects or entities to take advantage of that increased memory space will make it not-quake2.

164
Quake / Re: R1Q2 and Steam
« on: February 07, 2016, 03:15:31 PM »
The b8012 version of r1q2 is the last one released. The R1q2 updater is broken. R1ch went another direction with his web site and the updater wasn't redirected.

165
/dev/random / Re: AMC's The Walking Dead - Official Thread
« on: December 02, 2015, 09:31:39 AM »
I can ruin the whole thing for you. :)


https://youtu.be/jR4lLJu_-wE "La-Bibbida-Bibba-Dum"

https://youtu.be/-6BsMzc9mMs "Der der der der der!"

https://youtu.be/I0BnadYbLIU " I hope you're not afraid of owls 'cause I'm getting you one."

 :yessign:


https://youtu.be/Q9aM9Ch97U8 "la jiggy jar jar doo"

Pages: 1 2 3 4 5 6 7 8 9 10 [11] 12 13 14 15 16 17 18 19 20 21 ... 82