If I add another funtion to the Example DLL, will rFactor "see" it ?

JohnW63

I think my road block with altering the DLL and making one of my own out of it comes from not knowing what I can add and where I can put it. My understanding of DLLs in general, is they are a collection of "libraries" that another program calls. In this case, the program doing the calling is rFactor. I assume , that in the code that makes up rFactor are calls to the functions or structures or classes in the DLL. If that is correct, how would rFactor handle a new function or class of my own creation ? How would it know it was there to call ?

Because it has been suggested that I create new variables outside the functions or create my own static class to handle the variables I want to use, I am getting the impression that I am wrong about how this works.

Are there variables that can be used by any class, if I choose to create one, and use within it ? Could I create my own class that has variables in it that the Example.cpp has separated into Scoring and Telelmetry just for easier organization ?
 
rFactor calls the functions already in the example. Inside those functions you can call whatever you like. rFactor doesn't have to know anything about them.
 
But what if I add a NEW function ?

I would rather have a new class, than use global variables, if I can help it. If rFactor doesn't know how to call my function, then it won't work.
 
As I said... rFactor will only call the functions it already calls. But you can have hundreds of your own functions and call them from one of the existing ones, and that's fine. rFactor doesn't need to know about it.
 
So, what ever I do, I have to stay within the defined functions, used in the ExamplesInternalsPlugin class ? I sort of got the impression that the Examples.cpp file was just an example and that you could replace that with your own, as long as you used the same classes and structs that it used. I thought the important file was the InternalsPlugin.hpp file.

What I am frustrated by is that I can't use all the data that is streaming to make the output the way I want. If I am working with scoring, I have to stay in the scoring box. No using variables from other places. I'm fighting class encapsulation.
 
You have to store those values when they're available, to use when you want them. Look at mET - it's a class variable, defined in the .hpp, and can be read/altered in any function. Do exactly the same thing.
 
mET is a private variable, within the ExampleInternalsPlugin class. Since all of the functions used to output the data to a text file are from that class, it can be accessed. So, you're suggesting I make variables THERE. Is that correct ? Would they have access to function variables within the ExampleInternalsPlugin class as well, or would I need to alter those to have a return value to store, where applicable ?
 
??????

mET can be accessed within any function. So create a bool inPit variable in exactly the same way, set it (true or false) when you check your pit status in updateScoring, and when you're in updateTelemetry you can test the value of inPit and know if you're in the pit. Same for anything else you need to know.

The plugin isn't its own program, it's not running in a different thread. It's basically a collection of functions (and variables) that get added onto rFactor, and it expects some of them to be there and can call them accordingly. Any other functions you decide to make are for your own use, as are any variables you decide to make.

When UpdateScoring is running... that means rFactor at that moment is executing the code within UpdateScoring. No other parallel objects exist... it's just a simple (!) program.
 
I've been working on that. Declaring the variables, in the same location as the one you suggested worked for accessing them. My issue is initializing them. You can't assign an initial value there. I did a search of some of the others, in that section, like "mET" and "mEnabled" , and they are initialized in the EnterRealtime() of Example.cpp and the Startup section of that same file, respectfully.

I figured the best place to set my variables to a default value was in the EnterRealtime() It only gets called when you leave the garages. Unfortunately, that didn't work. It compiled, but when I check the state of one, the value is not true OR false. I don't want to set them in the updatetelemetry fuction because it would be reset 90 times per second.

A little more help would be really .... helpful.
 
Try setting them in Startup(). That's only called once when the game loads.
 
That sounds like a good spot to initialize them. I'll move those lines of code.

I am still concerned about why I was not getting either a "true" or "false" from these bool variables. I have a variable to determine if I have sent the tire info out to the test file already or not, called "mTireChangeReported". I wanted to test the state of this bool variable, because things were not getting printed out. The code is below:

Code:
if ( mTireChangeReported == true ) {
		fprintf( fo, " 1 mTireChangeReported is True \n" );
		}
		if ( mTireChangeReported == false ) {
			fprintf( fo, " 1 mTireChangeReported is False \n" );
		}
		else {
			fprintf( fo, " 1 mTireChangeReported is Neither \n" );
		}


It always outputs the third option.
 
Did you initialize the mTireChageReported correctly? Probably u missed out..

and put them as:

if (condition)
Action

else if(condition)
Action

else
Action
 
( Face Palm ! )

In the event that some other C++ noob needs to know this, the reason was simple. Comparision operator versus value assignment. In short "==" is not going to assign a value to a variable, but "=" will. It's amazing how long my eye scanned over that and it didn't register.
 

Back
Top