No announcement yet.

why I'm hesitant to crack jokes in my code...

  • Filter
  • Time
  • Show
Clear All
new posts

  • why I'm hesitant to crack jokes in my code...

    I wrote a lot of code that eventually had to make decisions around who won or lost. I finally went searching the game's code for a way to tell who won or lost. I saw calls to player:GetTeam():GetHasTeamLost() in game code, so I called player:GetTeam():GetHasTeamWon() where I needed it. Everything interpreted without error, and things seemed to be working, but I quickly noticed that it was detecting win/loss incorrectly. My code seemed to be recording losses when you won the game.

    I reviewed, and re-reviewed all of my code. I eventually found a friend to join the server so that I could test it without bots. Nope. Same problem. Or, rather, we determined, my code was recording losses no matter if you won or lost the game.

    Finally, after two hours of questioning my own code (with the help of another developer, as it's a few lines long), I decided to look for bugs in the game code. Surely I won't find a bug in the game code, right?

    Well... I wouldn't call it a bug, per se.... see if you can spot the problem!

    function PlayingTeam:GetHasTeamLost()
        if GetGamerules():GetGameStarted() and not Shared.GetCheatsEnabled() then
            // Team can't respawn or last Command Station or Hive destroyed
            local activePlayers = self:GetHasActivePlayers()
            local abilityToRespawn = self:GetHasAbilityToRespawn()
            local numAliveCommandStructures = self:GetNumAliveCommandStructures()
            if  (not activePlayers and not abilityToRespawn) or
                (numAliveCommandStructures == 0) or
                (self:GetNumPlayers() == 0) or 
                self:GetHasConceded() then
                return true
        return false
    // TODO: Returns true if team has acheived alternate victory condition - hive releases bio-plague and marines teleport
    // away and nuke station from orbit!
    function PlayingTeam:GetHasTeamWon()
        return false
    I'm all for a good laugh, but a quick "return not GetTeamHasLost()" would have been helpful, too! #facepalm
    Steam Community? Add me. | Free Remote, Encrypted Backup

    Darkilla: In short, NS is pretty much really fast chess. With guns. Apophis: I haven't seen anyone say that SM's are better than non-SMs. Nordbomber: This is THE first server I've seen where either side can comeback from out of seemingly nowhere with the right teamwork. en4rcment: I have NEVER experienced the type of gameplay that I have found here. Nightly I am amazed at the personalities and gaming talent. Zephyr: Apophis is clearly a highly sophisticated self-aware AI construct that runs on a highly modified toaster oven in Wyzcrak's basement.

  • #2
    Re: why I'm hesitant to crack jokes in my code...

    Nice TODO section




    TeamSpeak 3 Server




    Twitter Feed