Page 1 of 1

Help with a tool's code

Posted: Tue Oct 30, 2012 1:30 am
by ZurePitchmen83
I'm trying to make a modding tool for THPS3/4 and i can't compile it, more info here

http://thmods.com/forum/viewtopic.php?f=8&t=292

What do i need to do for it to compile?, i used wxDev-C++ 7.4.2.569 with Default GCC compiler

Re: Help with a tool's code

Posted: Tue Oct 30, 2012 6:18 am
by WhoElseButMe
first and foremost pkr files are not pre files
pkr files do contain the first version of pre files but they are NOT the same as anything thps3 and newer
There are several variables you will need to conform to in order to read and write these files properly, i'll let you figure those out on your own. You'll also want to use a method of parsing that can accept variable change, for files built by other tools and/or by hand.

Ultimately your problem is your items are out of scope and/or never instantiated at all

Code: Select all

public int CanBeSeenByAnotherMethod = 0;
public void PassTheSize()
{
   int size = 1000;
   int cantbeseenbyanothermethod = 2000;
   CanBeSeenByAnotherMethod = 3000;
   CatchTheSize(size, cantbeseenbyanothermethod);
}
public void CatchTheSize(int size1, int size2)
{
   // this will throw a compiler error because "cantbeseenbyanothermethod" is out of scope and "not declared"
   int newSize = 0;
   MessageBox.Show(string.Format("OldSize: {0}, {1}, {2}\nNewSize: {3}\nOutOfScopeInt: {4}", size1, size2, CanBeSeenByAnotherMethod, newSize, cantbeseenbyanothermethod));
}

You can either pass the variable to the method, declare the variable inside the method, or declare a property and asign a value to that property, but you CANNOT see a variable declared inside of another method, get it?

Re: Help with a tool's code

Posted: Tue Oct 30, 2012 6:36 am
by ZurePitchmen83
WhoElseButMe wrote:first and foremost pkr files are not pre files
pkr files do contain the first version of pre files but they are NOT the same as anything thps3 and newer

I knew that, Your code didn't work for me, i even removed the part you said wouldn't work and that didn't work either, i tried using prereaper's code and it didn't work either :(

Code: Select all

The error it throws at me

105 expected unqualified-id before 'public'
116 expected declaration before '}' token

What's wrong?, how can i properly read PRE files with no compiling error

Re: Help with a tool's code

Posted: Tue Oct 30, 2012 6:38 am
by WhoElseButMe
that code isn't written in wx whatever
it was for visual purposes only so you can see which objects were being declared and which one wasn't

In the code above you have 1 property and 2 methods. Both variables declared in method one are passed to method two so now method two can use their values. It can also use the property value because it isn't scope specific. The problem in the code above comes when I try and use the declared variables name from method one in method two which method two can't see. It doesn't exist as far as the second method is concerned, instead "size2" represents that variables value.

Re: Help with a tool's code

Posted: Tue Oct 30, 2012 6:40 am
by ZurePitchmen83
wxDev-C++ supports VC Compilers though, but they're not included, i don't know if they'll work with compiling my tool though, do i need to add something extra for your code to work? (like reading file header or something), i'm a beginner at C++

Re: Help with a tool's code

Posted: Tue Oct 30, 2012 6:52 am
by WhoElseButMe
you need to rewrite it for the code to work, its written in c#.
remove the public's and rewrite the messagebox in a way that wxDev likes and it should compile fine.
static string.Format is c# so you'll need to do something like
CString s;
s.Format(_T("OldSize: %d, %d, %d\nNewSize: %d\nOutOfScopeInt: %d"), size1, size2, CanBeSeenByAnotherMethod, newSize, cantbeseenbyanothermethod);
AfxMessageBox(s, MB_OK);