 |
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:16
|
|
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
};
Each element it is numbered the first is 0 and the following is one bigger so your slave has the number 6. Of course you should check whether your third parameter is out of range. Well of course in this case it would be a ChangeSpecialist function.
-Martin
|
|
|  |
 |
|
tombom
|
|
Pining for the fjords
Oct 2004 time: 05:16
|
|
I know this is the wrong place to put this, and I know this wouldn't be useful, but would this add a "to the power of" operator?
In SlicFrame.cpp after SOP_MULT in DoInstruction:
code:
case SOP_EXP:
sp = m_stack->Pop(type1, sval1);
Assert(sp >= 0);
sp = m_stack->Pop(type2, sval2);
Assert(sp >= 0);
sval3.m_int = Eval(type2, sval2) ^ Eval(type1, sval1);
m_stack->Push(SS_TYPE_INT, sval3);
break;
And in slic.y:
code:
expression: expression '+' expression { slicif_add_op(SOP_ADD); }
| expression '-' expression { slicif_add_op(SOP_SUB); }
| expression '*' expression { slicif_add_op(SOP_MULT); }
| expression '^' expression { slicif_add_op(SOP_EXP); }
With the bolded bit showing my addition.
|
|
|  |
 |
|
tombom
|
|
Pining for the fjords
Oct 2004 time: 05:16
|
|
Thanks for that. Do you think this will work?
For the first one:
code:
case SOP_EXP:
sp = m_stack->Pop(type1, sval1);
Assert(sp >= 0);
sp = m_stack->Pop(type2, sval2);
Assert(sp >= 0);
sval3.m_int = pow(Eval(type2, sval2), Eval(type1, sval1));
m_stack->Push(SS_TYPE_INT, sval3);
break;
With #include math.h at the top as well.
And then:
code:
%left '*' '/' '%'
%left '**'
at the top of slic.y.
code:
expression: expression '+' expression { slicif_add_op(SOP_ADD); }
| expression '-' expression { slicif_add_op(SOP_SUB); }
| expression '*' expression { slicif_add_op(SOP_MULT); }
| expression '**' expression { slicif_add_op(SOP_EXP); }
Where the second bit was.
I checked the lexer, as far as i can see you don't need anything.
Last edited by tombom on 23-01-2005 at 19:16
|
|
|  |
 |
|
tombom
|
|
Pining for the fjords
Oct 2004 time: 05:16
|
|
Thanks for your help.
One problem I'm running into now is that I have no idea how to set the ACTIVISION_ORIGINAL thing in the .y files. Martin's changes have this around them with no problems, but I can't get it to work.
Attached is the untested code without ACTIVISON_ORIGINAL. ^ is the operator.
Last edited by tombom on 23-01-2005 at 23:07
|
|
|  |
 |
|
tombom
|
|
Pining for the fjords
Oct 2004 time: 05:16
|
|
Here is the file since you can't attach something when editing. Sorry for this DP.
Attachment: slic.zip
This has been downloaded 1 time(s).
|
|
|  |
All times are GMT. The time now is 05:16. Apolyton Time is 00:16. |
top of page
|
|
|
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
|
|
|
|
|
|