Announcement

Collapse
No announcement yet.

Runaway loops

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Runaway loops

    I'm working on the BAM mapvote mod and have added a maplist command.

    So far I have 200 maps in a maplist.qc generated by a bash script. I've also integrated a MOTD feature. I'll release this as soon as I can fix the following problem:

    The is my function to list maps in the console:

    Code:
    void() list_maps=
    {
        local int i, x;
    
        for (i=0; i<VOTE_NUMMAPS; i++)
        {   
            sprint (self, number_to_map(i));
            sprint (self, " ");
            x++;
    
            // 10 columns
            if (x > 10) 
            {   
                sprint(self, "\n");
                x = 0;
            }   
        }   
    };
    This is how it's called:

    Code:
        if (self.impulse == VOTE_MAPLIST)
        {   
            list_maps();
            self.impulse = 0;
            return;
        }
    As you can see I reset self.impulse to stop any runaway loops. VOTE_MAPLIST is set to 222 and I have a 'maplist' alias set to impulse 222.

    Pretty simple stuff. The problem is that it generates a runaway loop error and I can't see why. I've also tried a while loop, but that has the same problem. VOTE_NUMMAPS is set to 200. While testing in the early stages I found that it would go to 231 maps, but 200 is a nice round number.

    Error:

    Code:
    SZ_GetSpace: overflow
    server Profile:
    [CallCount] [Statement] [BuiltinCt] [StmtTotal] [BltnTotal] [self]
    Host_Error: server runaway loop counter hit limit of 10000000 jumps
    tip: read above for list of most-executed functions
    QuakeC crash report for server:
    s4667: EQ_F        (=0), GLOBAL1689, GLOBAL511
    s4668: IFNOT      GLOBAL511, statement 4671
    s4669: RETURN     GLOBAL1688
    s4670: GOTO       , statement 4730
    s4671: EQ_F        (=0), GLOBAL1691, GLOBAL511
    s4672: IFNOT      GLOBAL511, statement 4675
    s4673: RETURN     GLOBAL1690
    s4674: GOTO       , statement 4730
    PRVM_GetString: Invalid constant-string offset (4698400 >= 43652 prog->stringssize)
                 : number_to_map : statement 743
    PRVM_GetString: Invalid constant-string offset (4759096 >= 43652 prog->stringssize)
                 : list_maps : statement 4
    PRVM_GetString: Invalid constant-string offset (4759096 >= 43652 prog->stringssize)
                 : vote_init_consider : statement 13
    PRVM_GetString: Invalid constant-string offset (4800712 >= 43652 prog->stringssize)
                 : W_WeaponFrame : statement 23
    PRVM_GetString: Invalid constant-string offset (4940144 >= 43652 prog->stringssize)
                 : PlayerPostThink : statement 7
    Client "Slacker" dropped
    Slacker left the game with 0 frags
    Quake Error: Host_Error: server runaway loop counter hit limit of 10000000 jumps
    tip: read above for list of most-executed functions
    While trying to debug it I've changed "sprint (self, number_to_map(i));" to just print "xxxx " to see if number_to_map() is a problem, but same bug occurs.

    Any ideas?

    -r0t.uk- cOOp - Mapvote - r0t.uk:26001
    -r0t.uk- DM - Mapvote - r0t.uk:26000

  • #2
    Well I've kind of got around this by integrating it into the bash script. Not really what I was hoping for, but it works:




    Here's the bash script: http://www.r0t.co.uk/scripts/create-maps.sh

    Obviously not much use for windows users, but maybe someone out there can write a .bat file that does the same, and I'll be happy to include it.

    -r0t.uk- cOOp - Mapvote - r0t.uk:26001
    -r0t.uk- DM - Mapvote - r0t.uk:26000

    Comment


    • #3
      well I can't figure out your infinite loop either but, x >10 is not 10 columns. At column 11 it is set to zero and column 12 becomes 1. x==10 - you want to reset columns at the end of 10.
      http://www.nextgenquake.com

      Comment


      • #4
        Yeah I wasn't really concerned too much so long as it all fitted on the screen. I've made it 8 columns now, so there's a bit of extra space for long map names.

        -r0t.uk- cOOp - Mapvote - r0t.uk:26001
        -r0t.uk- DM - Mapvote - r0t.uk:26000

        Comment


        • #5
          if you ever figure out the loop problem post the solution. I'm totally stumped. Oh and ++var is faster.
          http://www.nextgenquake.com

          Comment


          • #6
            weird. try using 200 instead of a global? dunno why it would matter.
            i have written my own 'warp' command that can support a large number of all maps ever made.

            i havent looked at Bam's code but mine just parses an impulse to point
            to an array of strings ( the filename ). then calls a changelevel from that.


            in my experience , where the loop starts put a counter inside and break out if its like, ten thousand. i know this is hacky.
            Last edited by R00k; 09-04-2014, 09:01 PM.
            www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

            Comment


            • #7
              I'd be interested to see your code. Using BAM's method I can only list 231 maps. After that the maplist command always breaks.

              I would have used arrays here but I thought I had read that quakec didn't support them?
              Last edited by slackhead; 09-04-2014, 09:04 PM.

              -r0t.uk- cOOp - Mapvote - r0t.uk:26001
              -r0t.uk- DM - Mapvote - r0t.uk:26000

              Comment


              • #8
                sure, i will post the code with a supporting tutorial how to implement and some
                explanations so anyone can use it .

                edit:
                ya vanilla quakec doesnt, and mine was written back in 2001 so im not actually using map[#] but a function of if x =# then string = 'foo'

                fteqcc will support True arrays though.
                www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                Comment


                • #9
                  We do need to see the number_to_map function, too.

                  Actually, the problem is that you can't have nested functions. So you'll need a temp variable:

                  Code:
                      string s;
                  
                      for (i=0; i<VOTE_NUMMAPS; i++)
                      {   
                          s = number_to_map(i));
                          sprint (self, s);
                          sprint (self, " ");
                          x++;
                  
                          // 10 columns
                          if (x > 10) 
                          {   
                              sprint(self, "\n");
                              x = 0;
                          }   
                      }

                  Comment


                  • #10
                    Originally posted by Zop View Post
                    We do need to see the number_to_map function, too.
                    Code:
                    string (float n)
                    number_to_map =
                    {
                        if (n == 1) return "e1m1";
                        else if (n == 2) return "e1m2";
                        else if (n == 3) return "e1m3";
                        else if (n == 4) return "e1m4";
                        else if (n == 5) return "e1m5";
                        else if (n == 6) return "e1m6";
                        else if (n == 7) return "e1m7";
                        else if (n == 8) return "e1m8";
                        else if (n == 9) return "e2m1";
                        else if (n == 10) return "e2m2";
                        else if (n == 11) return "e2m3";
                        else if (n == 12) return "e2m4";
                        else if (n == 13) return "e2m5";
                        else if (n == 14) return "e2m6";
                    
                    <snip>
                    
                        else if (n == 199) return "ikspq4";
                        else if (n == 200) return "ikspq5";
                        return string_null;
                    };

                    -r0t.uk- cOOp - Mapvote - r0t.uk:26001
                    -r0t.uk- DM - Mapvote - r0t.uk:26000

                    Comment


                    • #11
                      I made an edit to my last post- I found the problem.

                      Comment


                      • #12
                        Originally posted by Zop View Post
                        Actually, the problem is that you can't have nested functions.
                        It isn't nested. Can you explain what you mean?

                        Edit*

                        I think I know what you mean: using number_to_map() inside the sprint() function? I did try setting it first too, but that also errors out:

                        Code:
                        void() list_maps=
                        {
                            local int i, x;
                            local string s;
                        
                            for (i=0; i<VOTE_NUMMAPS; i++)
                            {   
                                s = number_to_map(i);
                                sprint (self, s); 
                                sprint (self, " ");
                                x++;
                        
                                if (x > 10) 
                                {   
                                    sprint(self, "\n");
                                    x = 0;
                                }   
                            }   
                        };
                        Same error as before.
                        Last edited by slackhead; 09-04-2014, 10:14 PM.

                        -r0t.uk- cOOp - Mapvote - r0t.uk:26001
                        -r0t.uk- DM - Mapvote - r0t.uk:26000

                        Comment


                        • #13
                          Code:
                          void() list_maps=
                          {
                              local int i, x;
                          
                              for (i=0; i<VOTE_NUMMAPS;[COLOR="Red"] i++[/COLOR])  //This causes your loop problem!
                              {   
                                  sprint (self, number_to_map(i));
                                  sprint (self, " ");
                                  x++;
                          
                                  // 10 columns
                                  if (x > 10) 
                                  {   
                                      sprint(self, "\n");
                                      x = 0;
                                  }   
                              }   
                          };
                          Change to:

                          Code:
                          void() list_maps=
                          {
                              local int i, x;
                          
                              for (i=0; i<VOTE_NUMMAPS; [COLOR="Lime"]i = i + 1[/COLOR]) //This allows for it to proceed without the loop. 
                              {   
                                  sprint (self, number_to_map(i));
                                  sprint (self, " ");
                                  x++;
                          
                                  // 10 columns
                                  if (x > 10) 
                                  {   
                                      sprint(self, "\n");
                                      x = 0;
                                  }   
                              }   
                          };
                          That will fix the runaway loop problem but I find it to be a lacking solution to listing that many maps. r00k probably has it right in using his warp code. But, it would be even nicer if you could just parse this stuff from a txt file. That way you could easily keep adding new maps via the txt file. It's possible you could use Frik_file to accomplish this. But lets see what r00k provides in his tut. I'll be thinking about this as well.

                          Comment


                          • #14
                            That fixed it. Thanks.

                            There are some problems that I may not be able to solve. Since there are a lack of string functions like len(), substr() etc. it may not be possible to nicely arrange the list in evenly spaced columns, which is what my bash script does. See http://www.r0t.co.uk/scripts/maplist.qc at the bottom (although the function is commented out, you can get an idea.)

                            I will wait for the warp solution though as it would be nice to have all 300+ maps listed.
                            Last edited by slackhead; 09-05-2014, 02:33 AM.

                            -r0t.uk- cOOp - Mapvote - r0t.uk:26001
                            -r0t.uk- DM - Mapvote - r0t.uk:26000

                            Comment


                            • #15
                              You could use a simple hack solution and just include that spacing like you've done in your list_maps () at the end of your bash to the number_to_map(). You would then basically get the same spacing as your list_map when it sprints each map name. Should be the same tho I haven't tested it myself.

                              Comment

                              Working...
                              X