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 22, 2016, 12:44:10 PM »
Quote from: beaver{KEA} on May 22, 2016, 08:01:55 AM
Quote from: beaver{KEA} on May 22, 2016, 08:01:55 AM
im just curious.
 if those 128 values were something higher. could i put more than 128 maps?
also is there such a thing as varchar? in this language?

There is no such thing as varchar in C.

In C you must manage the size of strings yourself. If you say char array[10]; then you can put 10 characters into that array. To be a string in C it must terminate with '\0' so that means 9 'printable' chars plus the nul. There is no such thing as a C string type and if you put more than 10 chars into it you have overflowed the array and the results are undefined -- the program can, and probably will, malfunction. This is where bugs live.

It's hard to say about that 128 array. Looking at the code, it's only used in one place and the actual maplist file is managed elsewhere in s_map.c and s_map.h and the size is managed dynamically. I see some strangeness going on between the maplist loading there and the actual map vote system. Let me look into this more deeply.

152
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 22, 2016, 12:02:37 PM »
Quote from: beaver{KEA} on May 22, 2016, 07:33:00 AM
Quote from: beaver{KEA} on May 22, 2016, 07:33:00 AM
im struggling through it all dont know anything about linux.
running 64 bit version os cent os 6.
i guess i got all the 32 bit libraries installed or whatever i needed to make everything work.

i cloned it this time.

after cloning do i just move the gamei386.so file into the ctf folder where i run my mod? or do i need to move all those object files too?

Good, if it's running you must have installed the 32-bit libraries correctly.
FYI, the instructions for adding the 32-bit libs are at the top of the makefile.

Yes, just move/copy the .so to the mod folder, you don't care about the object files.

153
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 22, 2016, 04:44:47 AM »
Post your map file, I'm not sure why that list should be wrong or where those commas should be coming from.

As for the messages in console, no, they won't crash the server but I've removed them in the changes yesterday, pull the code again and rebuild.

I hope you cloned the repository. Once cloned, all you need do to keep up is "git pull".

154
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 17, 2016, 12:09:16 PM »
That was easier to fix than I expected it would be. Try it out and see how it looks.

155
Trouble Shooting / Re: Help setting up Railwarz CTF Linux Server
« on: May 15, 2016, 09:35:06 PM »
Quote from: beaver{KEA} on May 15, 2016, 10:18:18 AM
Quote from: beaver{KEA} on May 15, 2016, 10:18:18 AM
just tried it out! the mapvote works perfect first try!

thank you! i can now convert my windows machine to linux!

i wasnt able to get map rotation to work properly ether or highscores working. nether are very important.

i do wish i could get wallfly setup on my server eventually.

but i will test  this new build out n see how it all goes!

Cool! Always nice when it works right the first time.
I looked at map voting and it looked broken to me, I have not touched the functionality at all so it's good to know it works at this stage.

I haven't looked at map rotation or highscores at all yet.
I've been re-stacking the code to be a little more organized so that any changes will be coherent going forward. Headers are all jumbled up and declarations are thrown around all over the place. I had a fun learning curve with GIT to get over as well.

I just found a bug that crashes the server involving the menu when you're dead. I'm tracking it down now.


156
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

157
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.

158
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;
}

159
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. :)

160
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.

161
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

162
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:

163
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.

164
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.

165
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...

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