D'oh got add slave working only problem is that it gives you one slave and also a pop.
Announcement
Collapse
No announcement yet.
Design: New SLIC functions
Collapse
X
-
"Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
-
there’s a problem after 7 to 9 turns the game spontaneously crashes. However I don't know if this is because of my add slave function or something that gets don’t by something I meddled with within my code.. the wired thing is it those not mater if I add 1 slave or 5 it always crashes around there."Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
-
Originally posted by The Big Mc
there�s a problem after 7 to 9 turns the game spontaneously crashes. However I don't know if this is because of my add slave function or something that gets don�t by something I meddled with within my code.. the wired thing is it those not mater if I add 1 slave or 5 it always crashes around there.
-MartinCiv2 military advisor: "No complaints, Sir!"
Comment
-
for slicfunc.cpp
Code:SFN_ERROR Slic_Addslaves::Call(SlicArgList *args) { if(args->m_numArgs != 2) return SFN_ERROR_NUM_ARGS; Unit city; BOOL res; res = args->GetCity(0, city); if(!res) { return SFN_ERROR_TYPE_ARGS; } sint32 count; if(!args->GetInt(1, count)) return SFN_ERROR_TYPE_ARGS; city = g_slicEngine->GetContext()->GetCity(0); if(!g_theUnitPool->IsValid(city)) { return SFN_ERROR_OK; } MapPoint pos; city.GetPos(pos); sint32 i; if(count > 0) { for (i=0; i
ChangePopulation(1); int owner = city.CD()->GetOwner(); city.CD()->AddSlaveBit(owner); city.CD()->ChangeSpecialists(POP_SLAVE, 1); } } else { for(i = count; i < 0; i++) { } } sint32 delta_martial_law; CityData *cd = city.GetData()->GetCityData(); cd->GetHappy()->CalcHappiness(*cd, FALSE, delta_martial_law, TRUE); return SFN_ERROR_OK; }
Code:SLICFUNC(SFR_INT, Addslaves);
"Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
-
Well one thing I wonder is why it returns SFN_ERROR_OK if the city is invalid. The other thing is why do you add always a pop when you just want to add a slave and what should the empty for loop if the given count is negative, I think there are times when you want to remove one but not all slaves. And actual what do you want with the for loops at all, the ChangeSpecialists function also accepts other values then 1 even negative values. And another thing is, that the slic function should also have a third parameter that gives the POP_TYPE. POP_TYPE is an enum and here it is:
Code:enum POP_TYPE { POP_WORKER, POP_SCIENTIST, POP_ENTERTAINER, POP_FARMER, POP_LABORER, POP_MERCHANT, POP_SLAVE, POP_MAX };
-MartinCiv2 military advisor: "No complaints, Sir!"
Comment
-
I re looked at my code and cut out a lot of the rubbish.
Code:SFN_ERROR Slic_Addslaves::Call(SlicArgList *args) { if(args->m_numArgs != 2) return SFN_ERROR_NUM_ARGS; Unit city; BOOL res; res = args->GetCity(0, city); if(!res) { return SFN_ERROR_TYPE_ARGS; } sint32 count; if(!args->GetInt(1, count)) return SFN_ERROR_TYPE_ARGS; city = g_slicEngine->GetContext()->GetCity(0); if(count > 0) { city.CD()->ChangePopulation(count); city.CD()->ChangeSpecialists(POP_SLAVE, count); } return SFN_ERROR_OK; }
However it still causes a crash."Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
-
Originally posted by The Big Mc
However it still causes a crash.
Well and now come to your problem, why do you assign a city again, even if you already got that city from the parameters, espeacilly, if you give that city a zero argument.
And another thing for namings of functions. It is easer to see what the function is called if you use: Slic_AddSlaves instead of Slic_Addslaves or should I pick a meaning: Slic_AddsLaves?
-MartinCiv2 military advisor: "No complaints, Sir!"
Comment
-
I do not do camel case
as for adding a pop before making it into a slave you have to or you get an error massage."Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
-
Originally posted by The Big Mc
I do not do camel case
Second question is then why using capitals at all?
Third questions why no underscores then?
Originally posted by The Big Mc
as for adding a pop before making it into a slave you have to or you get an error massage.
-MartinCiv2 military advisor: "No complaints, Sir!"
Comment
-
The error massage.
debug assertion failed!
Expression: workercount() >= delta
it goes on to point out this section of code
Code:void CityData::ChangeSpecialists(POP_TYPE type, sint32 delta) { Assert(type != POP_WORKER); if(type == POP_WORKER) return; if(delta > 0) { Assert(WorkerCount() >= delta); if(WorkerCount() < delta) return; } else if(delta < 0) { Assert(SpecialistCount(type) + delta >= 0); if(SpecialistCount(type) + delta < 0) return; } m_numSpecialists[POP_WORKER] -= (sint16)delta; m_numSpecialists[type] += (sint16)delta; if(type == POP_SLAVE) { if(m_numSpecialists[POP_SLAVE] <= 0) m_slaveBits = 0; } AdjustSizeIndices(); if(g_network.IsHost()) { g_network.Block(m_owner); g_network.Enqueue(this); g_network.Unblock(m_owner); } else if(g_network.IsClient()) { if(this == m_home_city.CD()) { g_network.SendAction(new NetAction(NET_ACTION_SET_SPECIALISTS, m_home_city.m_id, type, m_numSpecialists[type])); } } }
"Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
-
Originally posted by The Big Mc
The error massage.
debug assertion failed!
Expression: workercount() >= delta
it goes on to point out this section of code
-MartinCiv2 military advisor: "No complaints, Sir!"
Comment
-
but martin as you point out a always add a worker before converting them into a slave."Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
-
Originally posted by The Big Mc
but martin as you point out a always add a worker before converting them into a slave.
1st: It is limited to slaves.
2nd: It also adds a pop point, even if I don't want to add an pop point at the same time.
3rd: I cannot remove with it a slave.
With my suggestions you don't have these limitations. But of course if you don't add at the same time a pop you have to check whether there are enough workers for slave convertion first. And if you want to remove some specialist you have to be sure that there are not less specialists you want to remove. The way to check this is given in the ChangeSpecialists function.
-MartinCiv2 military advisor: "No complaints, Sir!"
Comment
-
Martin I understand you point but slaves are used in a different way to specialist.
A newbie on the slic front will look for an addslave function to add or remove a slave.
However the next function I will do is a change specialist which I will be able to do very fast ones I nailed the problem in the add slave function or I made modify this one. But you can’t expect me to learn the ways of the source with a foot long section of code as easy as a 5 liner.
As for my problem it starts when the city adds a pop by growing (but not it seams when the cheat mode ads one)."Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
Comment
Comment