Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 35 36 [37] 38 39 ... 57

Author Topic: Terra Vitae Fork (version 2.0 released!)  (Read 339499 times)

gentzy

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #540 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
Logged

gentzy

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #541 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)
« Last Edit: December 29, 2017, 07:29:03 pm by gentzy »
Logged

gentzy

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #542 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.
Logged

gentzy

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #543 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
« Last Edit: December 30, 2017, 02:31:44 am by gentzy »
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #544 on: December 30, 2017, 12:27:01 pm »

Oh, you have GDB? Oh, wonderful! I have not been able to get it to run on my machine!

I will work though your bug reports, thank you very much! I hopefully will release the next version today. One of those bugs I think has already been fixed.
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #545 on: December 30, 2017, 03:12:42 pm »

All right, fixing things...

...TVRecord_InputSleeperView is obsolete code and I just removed it. It didn't do anything useful.
Logged

gentzy

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #546 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
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #547 on: December 30, 2017, 09:01:45 pm »

I am very grateful for your fixing the bugs in the movie functions. Thank you very much!

The save1.3.dat to save1.4.dat bug had been fixed in the code, and will be released shortly (plus a number of new functions). I just need to test if the aim preference works.

Edit: fixed bug #1. If location is less than zero because your liberal is in hiding, then your liberal is infertile.


Edit: the aim specific code is buggy. Hold on...
« Last Edit: December 30, 2017, 09:05:59 pm by SlatersQuest »
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #548 on: December 31, 2017, 12:40:06 am »

Version 1.41 is ready, but DFFD is not allowing the upload (messages indicate server trouble). I will wait a day or two to see if this problem persists. If it does, I will look around for another option.
Logged

gentzy

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #549 on: December 31, 2017, 01:18:03 am »

Can you upload it anywhere else temporarily? I really wanted to mess with it today.
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #550 on: January 02, 2018, 12:49:55 am »

Version 1.41 released - get it at the usual place.

Logged

Eschar

  • Bay Watcher
  • hello
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #551 on: January 02, 2018, 02:44:14 pm »

What does canseethings keep track of?
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #552 on: January 02, 2018, 11:18:51 pm »

canseethings is a flag that tells the computer whether or not to print information to the screen and inform the player. It is normally false if all of the player's liberals are on vacation, in prison, disbanded, etc.
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #553 on: January 04, 2018, 01:46:30 pm »

All right, I realized that there is something lacking that should be accounted for regarding seduction. To wit:

1. Conservatives should be able to make unwanted advances on your Liberals
2. People whose hearts you sway should have angry Conservative spouses

I have some ideas on how to handle this - I've been thinking about ideas for an assassination system by which Conservatives might try to assassinate liberals using stealth rather than brute force, and this would be similar. However, I'd like your thoughts and suggestions, if you have any!
Logged

IsaacG

  • Bay Watcher
  • Mad Engineer
    • View Profile
    • JJoseph on Deviantart
Re: Terra Vitae Mod (version 1.4 released!)
« Reply #554 on: January 05, 2018, 11:22:02 am »

1.41 for Windows
http://www.mediafire.com/file/h18bu6o1l504hay/Terra_Vitae_1.41_for_Windows.zip

Meanwhile, IsaacG, can you give me a low-down of what the improvements to base LCS that you've made are and where they are in the code since I started work on TV? I'd like to bring this mod up to date with the rest of LCS, so any pointers of where to go and what needs to be updated would be very helpful!  :)

Here's an incomplete copy of what I'm working on.
http://www.mediafire.com/file/jycvrd8mal9w3xx/2017_2018_Getting_Terra_Vitae_Up_To_Date.pdf
Let me know if I should change my approach.  I actually haven't gotten to the major changes yet, but it is a start.
Logged
LCS 4.12 Thread
https://discord.gg/HYbss8eswM
Quote
Many people, meeting Aziraphale for the first time, formed three impressions: that he was English, that he was intelligent, and that he was gayer than a tree full of monkeys on nitrous oxide.
Constitution of the Confederate States
Article I Sec. 9 4
No bill of attainder, ex post facto law, or law denying or impairing the right of property in negro slaves shall be passe
Pages: 1 ... 35 36 [37] 38 39 ... 57