Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

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 - gentzy

Pages: [1]
1
Curses / Re: Terra Vitae Mod (version 1.4 released!)
« on: December 31, 2017, 01:18:03 am »
Can you upload it anywhere else temporarily? I really wanted to mess with it today.

2
Curses / Re: Terra Vitae Mod (version 1.4 released!)
« on: December 30, 2017, 08:25:45 pm »
Oh, you have GDB? Oh, wonderful! I have not been able to get it to run on my machine!
Not sure what you need to do in Macs, but in Linux all you have to do is install it using you package manager.
This is all I had to do:
Code: [Select]
sudo pacman -Syyu && sudo pacamn -S gdb

Very easy, see!  :P

3
Curses / Re: Terra Vitae Mod (version 1.4 released!)
« on: December 30, 2017, 01:18:48 am »
Here is a .patch file with all the changes I made previously: http://termbin.com/9dfi

Edit:
Bug 7: If you trigger a siege with only one squad member and then he gets shot the game will SEGV, that's because the game doesn't remove the squad until after the siege.
Fix is in this second patch: http://termbin.com/oed6

Apply the patches by doing the following:
Code: [Select]
wget <URL>
cd teravita/src
patch -p3 --ignore-whitespace < ../../<Name Of Downloaded file>
Then hit enter a couple times to tell it to ignore the binary files.

Edit:
One more patch, trying to graffiti in front of a crowd should warn you... too many of my squads have died to me not noticing.
http://termbin.com/nfzu

4
Curses / Re: Terra Vitae Mod (version 1.4 released!)
« on: December 30, 2017, 12:04:33 am »
Ok, changing phase III of the function to this fixes bug 4:
Code: [Select]
   //Phase III - who lives and who dies
   switch (alignment)
   {
      case ALIGN_ELITELIBERAL: //All good guys live, all bad guys die
         amsurvival = -abs(amsurvival);
         alsurvival = -abs(alsurvival);
         hmsurvival = -abs(hmsurvival);
         hlsurvival = -abs(hlsurvival);
         break;
      case ALIGN_LIBERAL: //One of the good guys dies, bad guys don't live
while (true)
{
randomint = LCSrandom(4);
if (randomint == 0 && pmsurvival)
{
pmsurvival = -1;
break;
}
else if (randomint == 1 && plsurvival)
{
plsurvival = -1;
break;
}
else if (randomint == 2 && smsurvival)
{
smsurvival = -1;
break;
}
else if (randomint == 3 && slsurvival)
{
slsurvival = -1;
break;
}
}
        amsurvival = -abs(amsurvival);
        alsurvival = -abs(alsurvival);
        hmsurvival = -abs(hmsurvival);
        hlsurvival = -abs(hlsurvival);
        randomint = LCSrandom(abs(amsurvival) + abs(alsurvival) + abs(hmsurvival) + abs(hlsurvival));
        break;
      case ALIGN_MODERATE: //33% of survival for everybody, but somebody on each side survives.
         if (LCSrandom(3))
            pmsurvival = -abs(pmsurvival);
         if (LCSrandom(3))
            plsurvival = -abs(plsurvival);
         if (LCSrandom(3))
            smsurvival = -abs(smsurvival);
         if (LCSrandom(3))
            slsurvival = -abs(slsurvival);
         if (LCSrandom(3))
            amsurvival = -abs(amsurvival);
         if (LCSrandom(3))
            alsurvival = -abs(alsurvival);
         if (LCSrandom(3))
            hmsurvival = -abs(hmsurvival);
         if (LCSrandom(3))
            hlsurvival = -abs(hlsurvival);

while (!(pmsurvival || plsurvival || smsurvival || slsurvival))
{
randomint = LCSrandom(4);
if (randomint == 0 && abs(pmsurvival))
{
pmsurvival = 1;
}
else if (randomint == 1 && abs(plsurvival))
{
plsurvival = 1;
}
else if (randomint == 2 && abs(smsurvival))
{
smsurvival = 1;
}
else if (randomint == 3 && abs(slsurvival))
{
slsurvival = 1;
}
}

while (!(amsurvival || alsurvival || hmsurvival || hlsurvival))
{
randomint = LCSrandom(4);
if (randomint == 0 && abs(amsurvival))
{
amsurvival = 1;
}
else if (randomint == 1 && abs(alsurvival))
{
alsurvival = 1;
}
else if (randomint == 2 && abs(hmsurvival))
{
hmsurvival = 1;
}
else if (randomint == 3 && abs(hlsurvival))
{
hlsurvival = 1;
}
}
        break;
      case ALIGN_CONSERVATIVE:  //One of the bad guys dies, one of the good guys lives
while (true)
{
randomint = LCSrandom(4);
if (randomint == 0 && pmsurvival)
{
pmsurvival = -1;
break;
}
else if (randomint == 1 && plsurvival)
{
plsurvival = -1;
break;
}
else if (randomint == 2 && smsurvival)
{
smsurvival = -1;
break;
}
else if (randomint == 3 && slsurvival)
{
slsurvival = -1;
break;
}
}

         amsurvival = -abs(amsurvival);
         alsurvival = -abs(alsurvival);
         hmsurvival = -abs(hmsurvival);
         hlsurvival = -abs(hlsurvival);

while (!(amsurvival || alsurvival || hmsurvival || hlsurvival))
{
randomint = LCSrandom(4);
if (randomint == 0 && abs(amsurvival))
{
amsurvival = 1;
}
else if (randomint == 1 && abs(alsurvival))
{
alsurvival = 1;
}
else if (randomint == 2 && abs(hmsurvival))
{
hmsurvival = 1;
}
else if (randomint == 3 && abs(hlsurvival))
{
hlsurvival = 1;
}
}
         break;
      case ALIGN_ARCHCONSERVATIVE: //good guys lose, bad guys win
         amsurvival = -abs(amsurvival);
         alsurvival = -abs(alsurvival);
         hmsurvival = -abs(hmsurvival);
         hlsurvival = -abs(hlsurvival);
         break;
      case ALIGN_STALINIST: //Only the "hero" survives - and the hero becomes evil by the end of the story
         pmsurvival = abs(pmsurvival);
         plsurvival = -abs(plsurvival);
         smsurvival = -abs(smsurvival);
         slsurvival = -abs(slsurvival);
         amsurvival = -abs(amsurvival);
         alsurvival = -abs(alsurvival);
         hmsurvival = -abs(hmsurvival);
         hlsurvival = -abs(hlsurvival);
         break;
      default: break;
   }

Now a fifth bug has revealed its left  ::)

Movie creation sometimes gives a SIGFPE (Arithmetic exception). This is because Film->budget can equal zero.
Code: [Select]
(gdb) down
#3  0x0000000100047b13 in mode_title () at title/titlescreen.cpp:618
#2  0x00000001000761c3 in mode_base () at basemode/basemode.cpp:565
#1  0x0000000100145dd2 in passmonth (clearformess=@0x7fffffffd60b: 1 '\001', canseethings=canseethings@entry=0 '\000') at monthly/monthly.cpp:777
#0  0x000000010006fe3a in Advance_Movie (Film=0x1011bcbe0, canseethings=canseethings@entry=0 '\000') at monthly/tvrecord.cpp:982

Changing line 982 from:
Code: [Select]
advanceprob = 5000000 / Film->budget;                                                                                                                        │
to:
Code: [Select]
    if (Film->budget == 0)
{
   Film->budget = -1;
}
    advanceprob = 5000000 / Film->budget;                                                                                                                        │
fixes the problem.

And here is the solution to bug 3: the game is set to save to saveTV1.3.dat but it loads from saveTV1.4.dat
Code: [Select]
$ ag -Qi "saveTV1.3"
daily/daily.cpp
38:   //*JDS* Save the game to saveTV1.3.dat each day.
39:   if(!disbanding&&autosave) savegame("saveTV1.3.dat");

title/titlescreen.cpp
620:   savegame("saveTV1.3.dat");

title/saveload.cpp
449:/* loads the game from saveTV1.3.dat */
1022:/* deletes saveTV1.3.dat (used on endgame and for invalid save version) */

includes.h
1481:/* loads the game from saveTV1.3.dat */
1483:/* deletes saveTV1.3.dat (used on endgame and for invalid save version) */

Replace all of those with 1.4 instead.

Tada! The game is now slightly stable-er.

5
Curses / Re: Terra Vitae Mod (version 1.4 released!)
« on: December 29, 2017, 06:44:59 pm »
I've learned about the watch command in gdb which has helped me to find where the location of disbanded squad members gets set to -1. It happens in line 1404 of daily.cpp.
Commenting out that line fixes the issue, but probably causes other bugs.

Reproducing bug 2 is now easier, just disband your squad and hold enter for a while.
More info on bug 2: something is setting LocalCreature to a number larger than 0x1a00000000

edit:
The cause of bug 2 is TVRecord_InputSleeperView's liblist is overflowing badly.
Code: [Select]
(gdb) dow
#0  TVRecord_InputSleeperView (viewnumber=viewnumber@entry=10, creaturetype=creaturetype@entry=61) at monthly/tvrecord.cpp:176
(gdb) print liblist
$40 = {30, 15, 12, 57, 88, 69, 91, 74, 87, 57, 69, 91, 74, 87, 57, 69, 74, 87, 13, 57, 91, 88, 77, 69, 91, 13, 74, 77, 87, 57, 88, 23, 33, 69, 91, 74, 87}
(gdb) print listlength
$41 = 118
(gdb) info watchpoint
Num     Type           Disp Enb Address            What
8       hw watchpoint  keep y                      *0x100c3a1d8
        breakpoint already hit 1 time
0x100c3a1d8 is LocalCreature's address
Code: [Select]
(gdb) print liblist[listlength]
$42 = 28
(gdb) print &(liblist[listlength])
$43 = (int *) 0x100c3a1d8 <namecreaturetype(int)::LocalCreature>

I have no clue what the code is supposed to do, but simply insuring that listlength is never >= VIEWNUM solves this issue therefore I changed this code:
Code: [Select]
void TVRecord_InputSleeperView(int viewnumber, int creaturetype)
{
   static int listlength = 0;
   static int liblist[VIEWNUM], stalist[VIEWNUM];
   int i, libcount, stacount, localview, numsleepers;
to this code:
Code: [Select]
void TVRecord_InputSleeperView(int viewnumber, int creaturetype)
{
   static int listlength = 0;
   static int liblist[VIEWNUM], stalist[VIEWNUM];
   int i, libcount, stacount, localview, numsleepers;

if (listlength >= VIEWNUM)
{
listlength = 0;
}

Fixing that exposes a fourth bug! Sometimes a movieactor has lover equal to -1 (they have none maybe? dunno, your code not mine). That can get passed down to Kill_Movie_Character which then tries to access movieactors[-1] which gives a SEGV...

Code: [Select]
(gdb) down
#5  0x0000000100047b13 in mode_title () at title/titlescreen.cpp:618
#4  0x00000001000762e3 in mode_base () at basemode/basemode.cpp:565
#3  0x0000000100145ef2 in passmonth (clearformess=@0x7fffffffd17b: 1 '\001', canseethings=canseethings@entry=0 '\000') at monthly/monthly.cpp:777
#2  0x0000000100070c84 in Advance_Movie (Film=0x1011c3d60, canseethings=canseethings@entry=0 '\000') at monthly/tvrecord.cpp:1199
#1  0x000000010006ca95 in Narrate_Movie_Events (genre=<optimized out>, protagonistview=<optimized out>, antagonistview=<optimized out>, alignment=3,
    canseethings=canseethings@entry=0 '\000') at monthly/tvrecord.cpp:3260
#0  0x0000000100069f04 in Kill_Movie_Character (characterindex=-1, andneeded=0, lovertakeupmysword=lovertakeupmysword@entry=0,
    List=List@entry=0x7fffffffccf0 "Raghad Matthews,") at monthly/tvrecord.cpp:2594

This can be fixed by checking that the characters actually exist before you try to kill them. Lines 3121 to 3240 should be doing this but arn't, I'll post a fix when I've got time. (3-4 hours from now)

6
Curses / Re: Terra Vitae Mod (version 1.4 released!)
« on: December 29, 2017, 01:35:40 am »
Hello,
I got 3 bugs to present:

A) Disbanding your squad currently gives a SEGV.

Steps to reproduce:
1- Start a game.
2- Press L then D
3- Type in the phrase.
4- Profit!

Whats happening is that when you disband the location of the squad members is set to "-1". Then: advanceday (clearformess=clearformess@entry=@0x7fffffffd78b: 1 '\001', canseethings=canseethings@entry=0 '\000') at daily/daily.cpp:1108 calls check_child_conception (Bearer=0x10116cb00) at daily/daily.cpp:2687 which then calls check_fertility (Me=0x10116cb00) at daily/daily.cpp:2782 which then checks for a negative location...

Solutions:
1) keep tracking their location after the squad is disbaned
2) guess their location
3) ignore their location

B) Game will randomly SEGV when continuing to next day.

Steps to reproduce:
A) Start a game
B) Advance the day for 1 month to forever.

This happened so few times that I couldn't debug it properly.

It happens when TVRecord_InputSleeperView calls namecreaturetype on line 201 (src/monthly/tvrecord.cpp) which then calls makecreature on line 46 (src/monthly/tvrecord.cpp). namecreaturetype passes *LocalCreature to makecreature, which sometimes is an invalid piece of memory (maybe the object got deleted by something?). makecreature than calls drop_weapon_and_clips on the creature it got passed (line 33, creaturetypes.cpp), which then tries to set LocalCreature's member variable has_thrown_weapon to false, which is an invalid piece of memory because LocalCreature doesn't exist.

And now the final bug:
The game doesn't load saves.

How to reproduce:
1) Confirm you have no ~/.lcs
2) Start crimesquad and start a game
3) Press X (Live to fight EVIL another day)
4) Notice how you know have an ~/.lcs with a save which probably is valid (I don't know how to check if is or not)
5) Start crimesquad again, notice how its asking to make a new save

7
Curses / Re: Terra Vitae Mod (version 1.2 released!)
« on: June 27, 2017, 02:53:06 pm »
Quote
No symbol "len" in current context.
Code: [Select]
creature/creature.h: #define CREATURE_NAMELEN 40

Code: [Select]
title/saveload.cpp:         fwrite(&lobbies[l]->LobbyName, sizeof(char), CREATURE_NAMELEN, h);
title/saveload.cpp:         fread(&lobbies[l]->LobbyName, sizeof(char), CREATURE_NAMELEN, h);

Looks to me this is the code that needs changing.
A quick fix is to replace instances of "CREATURE_NAMELEN" with the number 40.  Most, maybe all of them.  Definitely its appearances in saveload.cpp

Hopefully that's enough.
Tried switching both instances with 39, 40 and 41, no cigar.

"Quck change" should be just
Code: [Select]
#include "creature/creature.h"
"creature/creature.h" is included by "includes.h" which is included by "extern.h" which is included by "title/saveload.cpp" so that should not be necessary.

EDIT:

Found the issue, lobbies is uninitilized:
Code: [Select]
(gdb) list
952       lobbies.resize(dummy);
953       for (int l = 0; l < len(lobbies); l++)
954       {
955         auto h2 = fopen("lobbies", "r");
956
957          fread(&lobbies[l]->LobbyName, sizeof(char), CREATURE_NAMELEN, h2);
958          fread(&lobbies[l]->LobbyCreatures, sizeof(int), CREATURENUM, h2);
959          fread(&lobbies[l]->LobbyLaws, sizeof(int), LAWNUM, h2);
960          fread(&lobbies[l]->spectrum, sizeof(int), 1, h2);
961          fread(&lobbies[l]->alignment_max_liberal, sizeof(int), 1, h2);
(gdb) print sizeof(char)
$13 = 1
(gdb) print lobbies
$14 = std::vector of length 2, capacity 2 = {0x0, 0x0}
(gdb) print l
$15 = 0
(gdb) print lobbies[l]
$16 = (Lobby *) 0x0
(gdb) print lobbies[l]

EDIT2:
Issue is fixed by adding
Code: [Select]
lobbies[l] = new Lobby;before
Code: [Select]
fread(&lobbies[l]->LobbyName, sizeof(char), CREATURE_NAMELEN, h);

8
Curses / Re: Terra Vitae Mod (version 1.2 released!)
« on: June 26, 2017, 05:50:53 pm »
Hello,
I compiled a version of the game for linux (I know that's not officially supported) and the games sometimes crashes randomly, but that's not my main issue.

My main issue is that the games ALWAYS crashes when trying to load a save. I've also tried running the windows version on wine, same issue.

Steps to Reproduce:
1- remove ~/.lcs (if you have it)
2- Start game
3- Hit enter a couples times (advanced gameplay options have no effect on the crash), followed by any series of letters (to skip past character history), then enter  to finally generate the world
4- Hit X to close the game
5- Try to restart the game and get a segmentation fault

I've gathered a lot of data to help you debug it:
https://pastebin.com/MPUbjku6 (# are comments I left, ┗❯ is the terminal)

Pages: [1]