project-navigation
Personal tools

Author Topic: Research code  (Read 24336 times)

Hoehrer

  • Guest
Research code
« Reply #15 on: March 24, 2006, 07:14:34 pm »
I've just commited a function named R_GetName to cl_research.c

it's a very basic function (... there are alot more yet uncommited), but i always have problems handling the stringcopy and stringcompare functions because i get errors. I need to resolve this, becasue all the other functions will sue this alot :-/
Code: [Select]
../client/cl_research.c:417: warning: array subscript has type 'char'
../client/cl_research.c:436: warning: array subscript has type 'char'
../client/cl_research.c: In function 'R_GetName':
../client/cl_research.c:465: warning: passing argument 1 of 'strcmp' from incompatible pointer type
../client/cl_research.c:467: warning: passing argument 1 of 'strcpy' from incompatible pointer type


It compiles, but i'm sure this'll cause some problems. I'm not a c-guru (more of a perl one ;)) , so i'm a bit lost on this... any hints on what am i doing wrong?

Werner


PS: i've added an additional "techlist" command to prevent alot of unneeded tzpos and faster input ;) ... will not be needed after research is done.

oxyXen

  • Guest
Research code
« Reply #16 on: March 24, 2006, 07:33:48 pm »
Looks to me, like u choose the false arguments.

char *bla
  • is an array of pointers.

Try maybe
Code: [Select]
void R_GetName( char *id, char *name )

ox

Hoehrer

  • Guest
Research code
« Reply #17 on: March 24, 2006, 07:39:36 pm »
Quote from: "oxyXen"
Looks to me, like u choose the false arguments.

char *bla
  • is an array of pointers.

Try maybe
Code: [Select]
void R_GetName( char *id, char *name )


Ah, that was it ... many thanks to you ox :D

Werner

oxyXen

  • Guest
Research code
« Reply #18 on: March 24, 2006, 07:46:53 pm »
It's me again.

No prob :)

Seems like you are from Germany, maybe check this bacause of the stringtermination(\0)

ox

Hoehrer

  • Guest
Research code
« Reply #19 on: March 25, 2006, 12:56:06 am »
Quote from: "oxyXen"
Seems like you are from Germany,

Bin aus Östereich (Niederösterreich/Wien) , aber _fast_ richtig :)

Quote from: "oxyXen"
maybe check this bacause of the stringtermination(\0)

I know how termination and string-handling in c works in general, but i just dislike the way strings (muahaha string-length-handling and string2number conversions ...  that's a good one ;)) and parameter-handling works in c [1] ... other languages (not only perl) are designed to prevent most of the problems you can encounter .... but that's not the topic and doesn't help us (me) in this case ;)

Werner

[1] i know that i wouldn't have this problems if i used more C/C++, but nearly ever language i've seen/used until now has more and easier way to do this.

Hoehrer

  • Guest
Research code
« Reply #20 on: March 25, 2006, 01:16:09 pm »
Ok, i finally switched from the data stored in the inventory to the one in the research code/files.

To quote myself (svn log)
Quote
* MAJOR: Finally switched from researchNeeded/researchTime to data stored in the research.ufo ("technologies" list)
** drawback: Right now the internal name are used. There are several workarounds possible, but i aim for the full solution.


This it the second big step (after the parser) to a fully working research system :D

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #21 on: March 29, 2006, 07:36:46 pm »
i've added saving and loading to research stuff - but i'm not sure what is all needed to save/load the stuff. please have a look at the new code at the end of cl_research.c

btw. incremented savefile version to 3

Hoehrer

  • Guest
Research code
« Reply #22 on: March 29, 2006, 09:18:04 pm »
Quote from: "Mattn"
i've added saving and loading to research stuff - but i'm not sure what is all needed to save/load the stuff. please have a look at the new code at the end of cl_research.c

btw. incremented savefile version to 3


Cool. i'll have a look at it when i'm sure my last major commit didn't cause any problems, but it seems to be ok. The only thing i've added is the "time"! value, because this'll change when research progresses.

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #23 on: March 29, 2006, 09:34:37 pm »
time value is a float
i changed this to ReadFloat resp. WriteFloat functions. anything else? does it work?

Hoehrer

  • Guest
Research code
« Reply #24 on: March 29, 2006, 10:21:59 pm »
Quote from: "Mattn"
time value is a float
i changed this to ReadFloat resp. WriteFloat functions. anything else? does it work?


Ah, thanks.

Not completely. e.g Try researching tachyon-technology and the saving -> exit ufo:ai compeltly (just in case) -> loading.

But i need to figure out if this is a problem with researchtree-marking or save/loading.

Werner

Hoehrer

  • Guest
Research code
« Reply #25 on: March 29, 2006, 10:27:16 pm »
I've added RS_MarkResearchable after loading the values. This should fix loading/saving of the tech-tree. But this need some major testing.

An alternative would be to save statusResearchable as well. Is there a preferred way (static values vs. recalculated values)?

Werner

Hoehrer

  • Guest
Research code
« Reply #26 on: March 29, 2006, 10:44:51 pm »
are you sure one can use MSG_WriteByte (and read) on an enum like that:
Code: [Select]
typedef enum researchStatus_s
{
RS_NONE,
RS_RUNNING,
RS_PAUSED,
RS_FINISH
} researchStatus_t;


Just wondering
Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #27 on: March 30, 2006, 06:46:07 am »
yes, that should be ok

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #28 on: April 11, 2006, 09:03:16 pm »
@hoehrer:
assignment of scientists should only work when the research is started already - what do you think? or maybe start the research after assignenment automatically

Hoehrer

  • Guest
Research code
« Reply #29 on: April 11, 2006, 10:59:00 pm »
Quote from: "Mattn"
@hoehrer:
assignment of scientists should only work when the research is started already - what do you think? or maybe start the research after assignenment automatically


Yes, the semi-autmatic way was my plan.
As soon as you add a scientist to a research item you not only automatically assign a room, but also start the research. On the other hand removing _all_ scientists will pause the research.
Will add that behaviour when i get some time again.

I also planned to automatically add at least one scientist if the "start" button is pressed, but we'll see how that works out.

The most difficult thing with the research.system still remains the init-,  save- and load-behaviour for the research-tree and the employees in the base. Currently if you start a new game and research something you will get messed up data when then starting a new game again.

One question: Are the icons on the bottom to "start/resume" + "pause"  the research self-explaining without reading the tooltips?

Werner