Announcement

Collapse
No announcement yet.

E's Source Code attempts

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

  • E it does not help you if elem is NULL and you check whether rec is NULL, it will crash nevertheless. But actual the more interesting question is why is elem NULL. You just might hide here defect and the program still does not run as expected.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

    Comment


    • Thanks Martin. I'll try a check on elem == NULL. But I agree about hiding the defect. I don't understand why its crashing now where as before this code didn't check for a NULL elem.

      Was a NULL elem introduced somewhere? I'm going to need a little more explanation on whats going on here and what should fix it. thanks.
      Formerly known as "E" on Apolyton

      See me at Civfanatics.com

      Comment


      • E, I don't know more than you know about the problem. I don't know whether you used a set of modified files. Maybe you eleminated all the ProposalElements from your DiplomacyRecords. Or maybe in s_proposalTypeToElemIndex there is something broken. Or you just have a bad build and you just need to recompile everything. If you don't use the debug version you will probably never find out what happens there.

        -Martin
        Civ2 military advisor: "No complaints, Sir!"

        Comment


        • everything is from the 623 version of the revision. but it does occur during a saved game.
          Formerly known as "E" on Apolyton

          See me at Civfanatics.com

          Comment


          • I did this and it prevented the crash:
            Code:
            sint32 Diplomat::GetNewProposalPriority(const PLAYER_INDEX foreignerId, 
            							  const PROPOSAL_TYPE proposalType ) const
            {
            	Assert(s_proposalTypeToElemIndex[proposalType] < m_diplomacy[foreignerId].GetNumProposalElement());
            	
            	const DiplomacyRecord::ProposalElement * elem =
            		m_diplomacy[foreignerId].GetProposalElement(s_proposalTypeToElemIndex[proposalType]);
            
            //
            	if (elem == NULL)
            		return -1;
            //	
            	const DiplomacyProposalRecord * rec = elem->GetProposal();
            	if (InvalidNewProposal(foreignerId, rec))
            		return -1;
            
            	sint32 priority = -1;
            	(void) elem->GetSendPriority(priority);
            	return priority;
            }
            Formerly known as "E" on Apolyton

            See me at Civfanatics.com

            Comment


            • So E, what is now the the problem that caused to make elem to be NULL?

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • martin,
                I guess this thread is as good as any to ask, were you looking into changing the Const.txt DB into a cdb like the other files (like you did for civ and diffDB). Just wondering. the new format is easier to deal with and since I'm looking at adding a few const.txt flags I'd rather wait if you are looking at updating the ConstDB's handling.
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • Well the ConstDB is a special case. In comparision to other databses it doesn't contain any records. It is just a single record one. Of course I could make the parser so that it parses it as a record, but that would mean that all the entries must stay in their order.

                  Well actually I have more clue about converting the MapDB into the new format than the ConstDB. Since for the MapDB the amount of work is much less. Probably just something parsing sequentially.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment

                  Working...
                  X