Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Call To Power II > CtP2-Source Code Project > E's Source Code attempts
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
CivGroups
CTP2 Source Code Project (59): Not a Member - Join

bottom of page
  
Author
Thread   
Pages (3): [ 1   2   3   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 04-08-2005 02:34 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#31 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

quote:
Originally posted by Martin Gühmann
So g represents a good but of what type is this g? It shouldn't be a problem to guess if you know what type the argument of HasResource is of.


Not sure what you mean by "what type is this g" Not sure what you mean by "type." but g looks like a numeric value for the good so it matches the good number in the array of all goods of the game. And g passes that number to see if the city has that good. Hasesource looks like it just passes g and tels whether or not (true or false) if the city is collecting or that resource.

So I think I have to do something that checks true or false if he unit has the NeedsCity Good than it checks if true or false if the good is collecting it. I dig more but my try retyping the code and trying to compile it. I may get lucky.

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 04-08-2005 09:55 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#32 Report this post to a moderator
Tired of ads?

I messed with some code and had to monkey with the lines. And getting the true and false took a second or two. But I tested it on the warrior and it works EXCEPT that it only checks if there is a good yes or no. Not a specific good. So I feel a lot closer. How can I make it a specific good? I don'tthink there is a function to draw a specific good out...


code:
//Added by E - If Unit needs a city good it checks if the city has the resource if(rec->GetNeedsCityGood() > 0) { sint32 g; bool found = false; for(g = 0; g < g_theResourceDB->NumRecords(); g++) { if(IsLocalResource(g)) { if(HasResource(g) == TRUE && rec->GetNeedsCityGoodIndex()) found = true; break; } } if(!found) return FALSE; }


and here's the citydata.cpp.

Attachment: citydata.zip
This has been downloaded 0 time(s).

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 04-08-2005 21:37 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#33 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

Well E you didn't tell me about your design decision, whether you want it so that the mod can only specify one good per unit or multiple ones per unit. And if multiple ones per unit whether the player needs them all in the list or only one of them.

Second design decision. Actual you already told me that the unit should be allowed to build if the city collects the good or if it receives the good via trade.

Does HasResource tell you whether the city collects the good or receives it via trade?

What does tell you IsLocalResource about a certain kind of good?

quote:
Originally posted by E
Not sure what you mean by "what type is this g" Not sure what you mean by "type." but g looks like a numeric value for the good so it matches the good number in the array of all goods of the game.


Actual I asked you about the type of g like I asked for the return type of the HasResource method before. In your last code fragment you posted it is for instance a sint32 or in other words it is a signed long int. And you are right it is in the end a plain number that you can use to access a good in the Resource database, and all other data structures whose elements represents certain bits of information about goods and contain usually as much elements as the resource database.

So how many elements contain the following data structures:

Resources m_collectingResources;
Resources m_sellingResources;
Resources m_buyingResources;

I you don't know the answer take a look into the constructor of CityData.

And of course what represent these data structures, or better the data contained.

quote:
Originally posted by E
And g passes that number to see if the city has that good. Hasesource looks like it just passes g and tels whether or not (true or false) if the city is collecting or that resource.


Rethink the statement about the HasResource.

quote:
Originally posted by E
So I think I have to do something that checks true or false if he unit has the NeedsCity Good than it checks if true or false if the good is collecting it. I dig more but my try retyping the code and trying to compile it. I may get lucky.


It's more simple.

code:
if(HasResource(g) == TRUE &&


That's very bad code, HasResource(g) returns already TRUE or FALSE, no need to check it again.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 06-08-2005 00:32 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#34 Report this post to a moderator
Enter the AD-FREE zone

quote:
Originally posted by Martin Gühmann
Well E you didn't tell me about your design decision, whether you want it so that the mod can only specify one good per unit or multiple ones per unit. And if multiple ones per unit whether the player needs them all in the list or only one of them.


Really, for modders sake we ought to do all three but name them different things. But for now I'll try one good per unit.


quote:

Second design decision. Actual you already told me that the unit should be allowed to build if the city collects the good or if it receives the good via trade.

Does HasResource tell you whether the city collects the good or receives it via trade?

What does tell you IsLocalResource about a certain kind of good?


HasResource says collectinggood is great so I think it includes trade or both. IsLocal is only for cities that have it in the radius. atleast as I understand it.


quote:

Actual I asked you about the type of g like I asked for the return type of the HasResource method before. In your last code fragment you posted it is for instance a sint32 or in other words it is a signed long int. And you are right it is in the end a plain number that you can use to access a good in the Resource database, and all other data structures whose elements represents certain bits of information about goods and contain usually as much elements as the resource database.

So how many elements contain the following data structures:

Resources m_collectingResources;
Resources m_sellingResources;
Resources m_buyingResources;

I you don't know the answer take a look into the constructor of CityData.

And of course what represent these data structures, or better the data contained.

Rethink the statement about the HasResource.



It's more simple.

code:
if(HasResource(g) == TRUE &&


That's very bad code, HasResource(g) returns already TRUE or FALSE, no need to check it again.

-Martin


i'll take a look at it. I think I know what I have to do, just didnt have the chance to do it yet. Whats hard though is that when you use terms like constructor etc I look them up in my dummies book and the code there is similar but different from the ctp2. its the hard part of having a "crawl" book and look at a "running" code and I still barely got to "walking." My definition understanding is seriously lacking but I kind of unerstand howthings plug together.

but hell I was thrilled that I got the code partly working and I think I know what I have to do to get it working.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 06-08-2005 01:36 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#35 Report this post to a moderator
Tired of ads?

quote:
Originally posted by E
Really, for modders sake we ought to do all three but name them different things. But for now I'll try one good per unit.


Well that implies now some major design changes to your code. However what happens if you reduce the other two multiple things to one good meaning that the list only contains one good?

quote:
Originally posted by E
HasResource says collectinggood is great so I think it includes trade or both. IsLocal is only for cities that have it in the radius. atleast as I understand it.


You are right about IsLocalResource, but look closer on HasResource, the names inside that function are obvious.

quote:
Originally posted by E
i'll take a look at it. I think I know what I have to do, just didnt have the chance to do it yet. Whats hard though is that when you use terms like constructor etc I look them up in my dummies book and the code there is similar but different from the ctp2.


Well you have to get the terms constructor and destructor. Basically a constructor fills the object with values and finds and allocates free memory for its members. A destructor frees heap memory. That's necessary otherwise this memory on the heap is lost to the program. That's called a memory leak.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 06-08-2005 09:01 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#36 Report this post to a moderator
Lose 30 kilos (of popups)

Well my idea worked and the code now limits it to specific good.

code:
//Added by E - If Unit needs a city good it checks if the city has the resource if(rec->GetNeedsCityGood() > 0) { sint32 g; bool found = false; for(g = 0; g < g_theResourceDB->NumRecords(); g++) { if(IsLocalResource(g)) { if(HasResource(g) && rec->GetNeedsCityGoodIndex()== g) found = true; break; } } if(!found) return FALSE; }


But I I think because of the LocalRsource part when I trade it, the city can no longer produce it and the receiving city cant. Not exactly what I want but its useful because perhaps in a agame you have to choose between building sophisticated units (or buildings) or selling it for profit. I think Oil could be used for that.

Last edited by E on 06-08-2005 at 10:33

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 07-08-2005 00:21 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#37 Report this post to a moderator
Support Apolyton buy from Amazon

Well, E, your code is slow. It contains a lot of unnecessary stuff and actual it doesn't do what it was intended to do.

Again you told me that it was supposed to allow to build the unit in question if the city collects the good in question or received it via trade. So you want to check all the goods collected in the city radius. And all goods that the city is buying.

Then again you didn't answer these question:

quote:
Originally posted by Martin Gühmann
So how many elements contain the following data structures:

Resources m_collectingResources;
Resources m_sellingResources;
Resources m_buyingResources;


quote:
Originally posted by Martin Gühmann
And of course what represent these data structures, or better the data contained.


quote:
Originally posted by Martin Gühmann
Well that implies now some major design changes to your code. However what happens if you reduce the other two multiple things to one good meaning that the list only contains one good?


quote:
Originally posted by E
But I I think because of the LocalRsource part when I trade it, the city can no longer produce it and the receiving city cant.


That's wrong and you already answered the question about what you tell you the IsLocalResource method.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 07-08-2005 02:25 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#38 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

Yeah, I knew the buyresources was the problem but I was looking for code that lets me do a HasrEsource or isLocalResource for m_buyingresources. I figure I have to do a || or thing for it too.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 07-08-2005 02:45 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#39 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

quote:
Originally posted by E
Yeah, I knew the buyresources was the problem but I was looking for code that lets me do a HasrEsource or isLocalResource for m_buyingresources. I figure I have to do a || or thing for it too.


Actual you want to combine those Resources that are collected inside the city radius and that are received via trade. It shouldn't so difficuilt to put the pieces of the puzzle together.

And before I forget it: Answer the questions in my last post, or don't you want to do some progress?

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 10-08-2005 09:23 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#40 Report this post to a moderator
Got spare money?

quote:

So how many elements contain the following data structures:

Resources m_collectingResources;
Resources m_sellingResources;
Resources m_buyingResources;


elements? not sure what you mean, do mean functions? all we have is IsLocalResource and HasResource. I did try to create:

code:
//this city is buying some sint32 resource added by E 9-Aug-05 BOOL CityData::IsBuyingResource(sint32 resource) const { return m_buyingResources[resource] > 0; }

It didnt work because I got:
code:
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4850) : error C2039: 'IsBuyingResource' : is not a member of 'CityData' F:\SVN-Code\trunk\ctp2_code\gs\gameobj\citydata.h(147) : see declaration of 'CityData' F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4851) : error C2270: 'IsBuyingResource' : modifiers not allowed on nonmember functions F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4852) : error C2065: 'm_buyingResources' : undeclared identifier F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4852) : error C2109: subscript requires array or pointer type


I guess I have to do something with the sellingto code there but then I get into the whole identifying the city issue which I think is not what I need.


quote:

Originally posted by Martin Gühmann
And of course what represent these data structures, or better the data contained.


IsLocalResource appears to test if its collecting a resource in the cityradius. HasREsource check if it is collectingmore of a resource than its selling. So it looks likeit checks if it is NOT selling the resource that IsLocal.


quote:

Originally posted by Martin Gühmann
Well that implies now some major design changes to your code. However what happens if you reduce the other two multiple things to one good meaning that the list only contains one good?


NOt sure what you are implying here...Are you saying what I specify for the Unit affects how the NeedsCityGood works? Or are saying that since I said all three are whats preferred, I was only meaning in time we may not want to limit how resources are utilized to build things. Mainly since the discussion is pretty diverse on it. But for now I'll settle with whats in the radius and if its buying the resource.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 10-08-2005 21:11 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#41 Report this post to a moderator
Got spare money?

quote:
Originally posted by E
elements? not sure what you mean, do mean functions? all we have is IsLocalResource and HasResource.


I told you to take a close look on the Resource class, it contains a member called m_supply. That's an array of integers. To figure out how many elements it contains I told you to take a look on the CityData constructor. A constructor is this special function that has the name of the class, and the destructor by the way is a function with the same name but with a ~ in front it.

In the CityData constructor you can see that the members of type Resource are initialized with g_theResourceDB->NumRecords(), that means that the number of elements you have wrapped in these objects are equal to the number of records you have in the ResourceDB for each good one element.

Now you have to understand with these elements represent. So check the resource class. Espeacilly these add methods.

quote:
Originally posted by E
I did try to create:

code:
//this city is buying some sint32 resource added by E 9-Aug-05 BOOL CityData::IsBuyingResource(sint32 resource) const { return m_buyingResources[resource] > 0; }

It didnt work because I got:
code:
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4850) : error C2039: 'IsBuyingResource' : is not a member of 'CityData' F:\SVN-Code\trunk\ctp2_code\gs\gameobj\citydata.h(147) : see declaration of 'CityData' F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4851) : error C2270: 'IsBuyingResource' : modifiers not allowed on nonmember functions F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4852) : error C2065: 'm_buyingResources' : undeclared identifier F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4852) : error C2109: subscript requires array or pointer type


I guess I have to do something with the sellingto code there but then I get into the whole identifying the city issue which I think is not what I need.


Obviously you did not modify CtiyData.h. But however you don't need to add such a method, because you can use m_buyingResources, m_sellingResources, m_collectingResources

quote:
Originally posted by E
IsLocalResource appears to test if its collecting a resource in the cityradius. HasREsource check if it is collectingmore of a resource than its selling. So it looks likeit checks if it is NOT selling the resource that IsLocal.


I think this is right but for clearity I reword it. It checks whether the good in question is in the city radius and that the city does not sell it.

quote:
Originally posted by E
NOt sure what you are implying here...Are you saying what I specify for the Unit affects how the NeedsCityGood works? Or are saying that since I said all three are whats preferred, I was only meaning in time we may not want to limit how resources are utilized to build things. Mainly since the discussion is pretty diverse on it. But for now I'll settle with whats in the radius and if its buying the resource.


I gave you three possibilities:

First the only one good choice.
Second the at least one of good choice.
Third the all good choice.

The first possibility contain only one good:

First case:

good1

The last two posibilities consits of lists of goods:

Second case:

good1
||good2
||good3
||good4

Third case:

good1
&&good2
&&good3
&&good4

So again what happens if you reduce the list in case 2 and 3 to just one element, so that only the first element of these list is left for instance?

-Martin

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 18-08-2005 22:46 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#42 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

Well E, I think you need again some push, otherwise you will answer in a month when I will have forgotten what you were trying to do here.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 18-08-2005 22:57 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#43 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

Sorry, the last week I havent been able to do much on my home computer. All apolyton contact has been at work

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 20-08-2005 09:16 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#44 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

Martin,

I'm kind of stumped I tried:

code:
if(HasResource(g) || (m_buyingResources[g] ) && rec->GetNeedsCityGoodIndex()== g)


AND...
code:
if(HasResource(g) || (m_buyingResources[g] > 0) && rec->GetNeedsCityGoodIndex()== g)


I based my stuff off of HasResource used the m_collectingresource[resource] and although it compiles when I try to trade with a city the city cant build the Unit.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 21-08-2005 02:48 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#45 Report this post to a moderator
Suffering from ads?

E, come on, you should answer my question first.

quote:
[SIZE]Originally posted by E[/SIZE]
I gave you three possibilities:

First the only one good choice.
Second the at least one of good choice.
Third the all good choice.

The first possibility contain only one good:

First case:

good1

The last two posibilities consits of lists of goods:

Second case:

good1
||good2
||good3
||good4

Third case:

good1
&&good2
&&good3
&&good4

So again what happens if you reduce the list in case 2 and 3 to just one element, so that only the first element of these list is left for instance?


That shouldn't be too difficuilt now. Or are you affraid that the answer could reduce a little bit your work, E?

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 22-08-2005 23:57 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#46 Report this post to a moderator
Got spare money?

Martin, I'm going to go withe first case. Its the one that applies best to CtP2 right now.

Civ3 lets you build colonies that sends goods to cities and you can share via network. In this NeedsCityGood it makes it only in a radius or by trade so if I make it many gods than it will be impossible to make a unit. So lets go with just one good, mainly since my code seems structured to it now.

there are other things we need to do with goods but I think NeedsCityGood will be a good start (and could make the AtG scenario more interesting once we get around to fixing that).

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 23-08-2005 00:22 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#47 Report this post to a moderator
Support Apolyton, buy Call to Power 2

quote:
Originally posted by E
Martin, I'm going to go withe first case. Its the one that applies best to CtP2 right now.


You gottn't my question, so again:

Case 1:

good1


Case 2

good1
||good2
||good3
||good4


Case 3

good1
&&good2
&&good3
&&good4

What happens if you put in the list of case 2 and case 3 just one element, for visualization I used the strike out. Once you have answered this question, ask yourself whether you still need to implement case 1.

Now answer this question and post the answer. And just to make it clear, I won't help you until you will have answered my question.

And now it shouldn't be too difficuilt anymore.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 23-08-2005 01:39 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#48 Report this post to a moderator
Full PM-box? Change here!

ok, in "or" statements the city must have good1 or good2 or good3 in order to build the unit. (aka the function will return true if the city has and of the "or" goods, kind of like what ahappened with my first code hen it passed any good in the radius)

in the "and" statements the city must have all of the goods in order to build it (aka the function will return false if any of the && statements are false)

If a "or" is not there then the function will still return true if you have good1 but no other goods.

In the "and" case it will return false if the good is not there when you try and build the unit.


this is based on my assumption that you meand the good1 etc is the good listed in the needscitygood part, or were refering to the good in the DB? or the good that has to be in the radius?

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 23-08-2005 01:54 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#49 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

You gottn't my question. Look at the lists with the strike outs. You don't need to have any knowledge about C++ or any knowledge about the source code of CTP2, just look at the cases in my previous post.

There you see that case Case 2 and Case 3 are the multiple ones. They are lists containing four elments or entries or whatever you want to call them. You don't need to put more then one element into these lists, you can put just one element into such a list. This is visualized by the strike outs. Now if you remove the striked out elements, what happens to Case 2 and Case3, especially if you compare them to Case 1.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 23-08-2005 02:05 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#50 Report this post to a moderator
Enter the AD-FREE zone

as you said before:
quote:

First the only one good choice.
Second the at least one of good choice.
Third the all good choice.



So you are saying that case2 and case3 will meet the requirements of case 1. Ok. But right now I don't need to code multiple goods because the other game elements don't help.

To me it looks like you are asking if I want to include multiple good stuff in an either or/and case. Civ3 uses AND but we can use OR also, which I can code later. Right now I just want to get if a city has a good OR is is buying a good.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 23-08-2005 02:17 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#51 Report this post to a moderator
Support Apolyton or Terrorists Win

quote:
Originally posted by E
So you are saying that case2 and case3 will meet the requirements of case 1.


To reword it a little bit, if you just put one element into these lists of case2 and case3, then they become case1. The consequence is that implementing case1 is useless, as you get it if you implement one of the others. And as you think that case2 and case3 are of use, so why bothering with case1?

quote:
Originally posted by E
Ok. But right now I don't need to code multiple goods because the other game elements don't help.


I don't understand this sentence.

quote:
Originally posted by E
To me it looks like you are asking if I want to include multiple good stuff in an either or/and case. Civ3 uses AND but we can use OR also, which I can code later. Right now I just want to get if a city has a good OR is is buying a good.


I don't know which one is easier, but you already implemented similar code for the OR case, for instance the culture only code is something like this. Or your intended Civ only code.

-Martin

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 23-08-2005 02:40 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#52 Report this post to a moderator
Lose 30 kilos (of popups)

Well to answer now your question.

Whether you have multiple version or single version of GetNeedsCityGoodIndex it returns a resource database index, that's an integer.

m_buyingResources and m_collectingResources store the number of goods the city receives or collects respectively. Both have the size of the resource database. Therefore the [] operator accepts resource database indeces, which as is said are numbers.

By the way you just want to know whether the entry in one of them is bigger zero. So sum the numbers and then do the check, should save a one or two operations.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 26-08-2005 22:33 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#53 Report this post to a moderator
Put an end to popups!

thanks Martin, tonight or tomorrow I should be able to get to it. Once this is done I think I'm going to try adding that pop-up about if you want to attack someone you are at peace with. its needed I think.

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 27-08-2005 10:39 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#54 Report this post to a moderator
Get a bigger avatar today!

Finally it works!

code:
if(rec->GetNeedsCityGood() > 0) { sint32 g; bool found = false; for(g = 0; g < g_theResourceDB->NumRecords(); g++) { if((m_buyingResources[g] + m_collectingResources[g]) > 0) { if((HasResource(g) || m_buyingResources[g]) && rec->GetNeedsCityGoodIndex()== g) found = true; break; } } if(!found) return FALSE; }


but you mentioned it was slow before, is there any way to optimize it? I'll post it once you approve

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 27-08-2005 22:05 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#55 Report this post to a moderator
Support Apolyton, buy Call to Power 2

But this doesn't look like the CityStyleOnly for instance. And GetNeedsCityGoodIndex requires one argument, in the Case2. And cycling through the whole resource database is a waste of time, your CityStyleOnly code doesn't cycle through thewhole city style database, either. Just through the elements of CityStyleOnly.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 28-08-2005 05:27 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#56 Report this post to a moderator
Enter the AD-FREE zone

when I pased g through NeedsCityGood it said that it does not take an argument.

I tried copying the citystyle a few times and got A LOT of errors. I assue you were talking about the line in bold which I used to try to match NeedsCityGood == m_buyingresources but it was not having it.

code:
// Added by E - Compares Unit CityStyle to the CityStyle of the City if(rec->GetNumCityStyleOnly() > 0) { sint32 s; bool found = false; for(s = 0; s < rec->GetNumCityStyleOnly(); s++) { if(rec->GetCityStyleOnlyIndex(s) == m_cityStyle) { found = true; break; } } if(!found) return FALSE; }

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 28-08-2005 20:20 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#57 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

quote:
Originally posted by E
when I pased g through NeedsCityGood it said that it does not take an argument.


Of course to make it accept multiple entries you have to modify the according *.cdb file. And when you are doing it add an NeedsCityGoodAll flag, this isn't far away once you have done this.

quote:
Originally posted by E
I tried copying the citystyle a few times and got A LOT of errors. I assue you were talking about the line in bold which I used to try to match NeedsCityGood == m_buyingresources but it was not having it.


Of course this equal check doesn't work, NeedsCityGood isn't defined anywhere.

quote:
Originally posted by E
code:
// Added by E - Compares Unit CityStyle to the CityStyle of the City if(rec->GetNumCityStyleOnly() > 0) { sint32 s; bool found = false; for(s = 0; s < rec->GetNumCityStyleOnly(); s++) { if(rec->GetCityStyleOnlyIndex(s) == m_cityStyle) { found = true; break; } } if(!found) return FALSE; }


Actual I told you how the condition instead of the bold line looks like. If the sum of collecting and buying resources is bigger zero, then you have found it, and the type of resource you want to check comes out of GetNeedsCityGoodIndex method.

So basical you have to modify one line in a *.cdb file and three lines in your code and delete another line. And of course you have to fix the indention.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:18
  Old Post 28-08-2005 21:56 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#58 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

quote:
Originally posted by Martin Gühmann


Of course to make it accept multiple entries you have to modify the according *.cdb file. And when you are doing it add an NeedsCityGoodAll flag, this isn't far away once you have done this.


modify the cdb? I think I know what I have to do....
NeedsCityGoodAll flag...are you intending that if one city has a resource or is buying resource than the unit is available to all cities?


quote:

Of course this equal check doesn't work, NeedsCityGood isn't defined anywhere.


Thats what the compiler said

quote:

Actual I told you how the condition instead of the bold line looks like. If the sum of collecting and buying resources is bigger zero, then you have found it, and the type of resource you want to check comes out of GetNeedsCityGoodIndex method.

So basical you have to modify one line in a *.cdb file and three lines in your code and delete another line. And of course you have to fix the indention.

-Martin



I assume these are the bold I need to modify. I guess I need to combine them?

code:
if(rec->GetNeedsCityGood() > 0) { sint32 g; bool found = false; for(g = 0; g < g_theResourceDB->NumRecords(); g++) { if((m_buyingResources[g] + m_collectingResources[g]) > 0) { if((HasResource(g) || m_buyingResources[g]) && rec->GetNeedsCityGoodIndex()== g) found = true; break; } } if(!found) return FALSE; }

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:18
Post  Old Post 28-08-2005 22:46 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#59 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

quote:
Originally posted by E
modify the cdb? I think I know what I have to do....
NeedsCityGoodAll flag...are you intending that if one city has a resource or is buying resource than the unit is available to all cities?


No, actual this is Case3. Easy to implement once you have done Case2.

quote:
Originally posted by E
I assume these are the bold I need to modify. I guess I need to combine them?

code:
if(rec->GetNeedsCityGood() > 0) { sint32 g; bool found = false; for(g = 0; g < g_theResourceDB->NumRecords(); g++) { if((m_buyingResources[g] + m_collectingResources[g]) > 0) { if((HasResource(g) || m_buyingResources[g]) && rec->GetNeedsCityGoodIndex()== g) found = true; break; } } if(!found) return FALSE; }


Not quite, you got 2 of 3 to modify, but the line to delete is under the bold.

-Martin

Maquiladora is offline Maquiladora
Emperor

Jun 2001
time: 05:18
  Old Post 28-08-2005 23:43 Visit Maquiladora's homepage!
Edit/Delete Message Reply w/Quote
#60 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

quote:
Originally posted by Martin Gühmann
No, actual this is Case3. Easy to implement once you have done Case2.


This is something I was gonna suggest, excellent Being able to build a unit in all cities, with the Good anywhere in your civ that is.

Also, I tried to use two NeedsCityGood flags for one unit but it didnt work in the game (didnt cause a fault), I assume it wasnt implemented. Is this possible to implement too?

 
Pages (3): [ 1   2   3   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:18.
Apolyton Time is 00:18.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0712 seconds (93.89% PHP - 6.11% MySQL) with 36 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net