| 07-16-2007, 02:41 AM | #1 | |
Im working on a program for editing WAI and other scripts, and I have a problem. Im trying to use the managed type String, in an unmanaged struct. How am i going to use two strings in this unmanaged struct because the strings have no char limit and if i impose a limit, that might be problematic. Any help would be appreciated. I'll post the two important files here. Note: Stdafx.h is an empty file in case u try to compile.. This is written in Visual C++ in Visual C++ 2005 Express with Windows PSDK (R2).Also, one more question. What is the difference between LoWord and HiWord? Quote:
|
| 07-16-2007, 07:37 PM | #2 | ||
Quote:
Quote:
|
| 07-16-2007, 07:51 PM | #3 |
can you have a managed struct in an unmanaged class? I tryed using a managed class and struct but I couldnt create char arrays. I use string for; AI Name, Map FIle, condition names, ect. And about the HiWord/ LoWord. How would I distingish the two when programming? I'm not fully versed in this kinda stuff. I'm just using previous programming skills to leverage me into VC++. |
| 07-16-2007, 08:30 PM | #4 | ||
Quote:
Quote:
|
| 07-16-2007, 09:20 PM | #5 |
ok, thanks, your explanation really helped. Ok, one final question; is there anyway to put an array in managed array, IE; Code:
ref struct Random {
char Rawcode[4]; // The [4] causes a compilation error
String ^ ConditionName;
};Code:
struct Random {
char Rawcode[4];
String ^ ConditionName; // Now this line causes compilation problems...
}; |
| 07-17-2007, 11:25 AM | #6 | |
Quote:
array<unsigned char>^ myBuffer = gcnew array<unsigned char>(4); |
| 07-17-2007, 05:46 PM | #7 |
lol! Thanks! Ill test it later! +REP One more thing... so, based on the example i gave below with the 0x0001 and others... if what you say is true, then 0x00010841 would toggle Smart Artillery, Melee, Buy Items, and have no mercy... right? ugh, not anotther problem, I used this code: Code:
public ref class WAI
{
public:
int _FILEVERSION;
String ^ AIName;
int race;
int options;
int BuildingsAndWorkers;
array<unsigned char>^ GoldWork = gcnew array<unsigned char>(4); // 4 Single Dimensional Array
//char WoodWork[4];
//char BaseBuild[4];
//char MineBuild[4]; // End Arrays
int numconditions;
int Unknown;
char HeroOne;
char HeroTwo;
char HeroThree;
int OneTwoThreePercent;
int OneThreeTwoPercent;
int TwoOneThreePercent;
int TwoThreeOnePercent;
int ThreeOneTwoPercent;
int ThreeTwoOnePercent;
//char OneAsFirst[10][4]; // 4*10 multidimensional array
//char OneAsSecond[10][4];
//char OneAsThird[10][4];
//char TwoAsFirst[10][4];
//char TwoAsSecond[10][4];
//char TwoAsThird[10][4];
//char ThreeAsFirst[10][4];
//char ThreeAsSecond[10][4];
//char ThreeAsThird[10][4]; //End Arrays
int BuildPriorities;
int HarvestPriorities;
int TargetPriorities;
int RepeatsWaves;
int MinimumForces;
int InitialDelay;
int AttackGroups;
int AttackWaves;
int UnknownTwo;
int GameOptions;
int GameSpeed;
String ^ MapPath;
int Players;
int Unknown3;Code:
c:\documents and settings\administrator\my documents\visual studio 2005\projects\aitool\aitool\AITooL.h(16) : error C3845: 'AITooL::WAI::GoldWork': only static data members can be initialized inside a ref class or value type I think i know whats wrong. Im not supposed to give variables a value in a struct/class unless they are prefixed with constant. |
| 07-20-2007, 10:37 AM | #8 | |
array< unsigned char,2 >^ OneAsFirst = gcnew array< unsigned char,2 >( 10, 4); // 2 dimension array, 10x4 Quote:
Solution: Just declare it on the struct and then initialize it on the constructor. Code:
public ref class WAI
{
public:
int _FILEVERSION;
...
array<unsigned char>^ GoldWork
...
WAI()
{
GoldWork = gcnew array<unsigned char>(4);
}
... |
| 07-20-2007, 05:58 PM | #9 |
Ok, i have been away for this week or this problem would have been long ago solved: First, why do you need to use managed strings when you can use character pointers? Second, if the only reason that you would be using those is for their internal methods, then use the c++ comparisons like strcmp and others. BD is quite correct about the GoldWork variable, and i completely agree with BD; stick with one or the other, mixing managed and unmanged is just not the best thing to do... I like unmanaged personally, but the managed framework has a fair amount of usable material. Quick Question: are you using BD's Library, which would be the reason for needing managed code? |
| 07-21-2007, 12:54 AM | #10 |
Im hoping to create an ai implement that is integratable with BD's library. The string will be written to a file so i cant use comparisons. Thanks BD... that method worked like a charm... Id shower rep but i cant :( |
| 08-23-2007, 12:45 AM | #11 |
TSA, did this ever get finished? |
| 09-08-2007, 04:19 PM | #12 |
no, alot of the data on the W3M/W3X needs to be updated and so im trying to do some reasearch on the WAI format. And plus i got grounded for about a month but im about to plug some new stuff in, dont worry ill make a announcement when its done. |
