For that particular functionality you can never know how big a buffer will be. Consider the case; ConsoleFormat("Blah %s, %s", "String of unknown length", "another unknown"); so you will never know. Either choose a high number and watch what you send in or have some idea of what your doing.
If you knew the size you could use dynamic memory. 'new' / 'malloc' and remember to call 'delete' / 'free' respectively. However, starting out, I would use the fixed size array, and make a solid note of the assumption and possible failure. The dynamic allocation won't work in this situation because you don't know the size of buffer you would need. So again you're stuck to some number that could be too small.
Like I've said, I've used that function and never run out of room, but I know it has limits and I don't use that function for dumping lots of data.
----------------
The final option, which I've used before is to allow the "caller" to send in their own buffer:
You could take in the bufferSize if needed as well, but this allows the caller to do something like.
char *pBigBuffer = new char[1024*1024*100]; //100mb buffer should be big enough for anything. Worry about running out of memory/slow allocation... ConsoleFormat(pBigBuffer, "%s%s%s", codeDump, dataDump, logDump"); delete [] pBigBuffer;
that is obviously not reccomended but pretend all the 'dumps' are large character arrays that end with a null-terminator of course since printf %s requires that. But since they are large they might fill a really big space, and in this version of the function it is flexible enough to do that. You can't have both functions because of the ... -the compiler won't know which to call. You can rename it ConsoleFormat and ConsoleFormatBig.
Last edited by blackbird04217, .
Reason : spelling
Okay guys some more fun action! I hope this doesn't cause out of sync errors... I've watched it three times and restarted my copy of LFS...
Here is the update; the AI shifts up/down at predetermined RPM settings. When the RPM drops below 1000 the AI applies full clutch to avoid stalling. Again the false start is my fault, mostly lack of patience to run a test.
You get to see the AI do something almost every player did their very first time entering a corner... It also happens quite frequently in the online environment from what I hear, haven't been there in ages...
Note that this is poor since if the string and inputs exceed 1kb it _WILL_ crash because you will run out of space within szBuffer. I've never used this with special 'large' cases and in practice I've never had an issue.
In my opinion this is more flexible, however for the needs of InSim, where the type is defined as a 3, 4byte floating point values for a Vec., I would stick with;
struct Vec { float x; float y; float z; };
But, this is half-dozen one way to a half dozen the other. Just my opinion on the 'fixed' status of the packets types. No need to further complicate things by accidentally typing Vec<int> somewhere you meant for a float.
I don't know why its not included, although my ideas are so you could do them yourself. 'byte' is commonly defined as unsigned char, but what it in some application they had defined it as char, first there would be errors of redefinition and second strange things might happen. Another possibility is that since InSim, OutSim and OutGauge work through sockets, it is language, compiler and platform independent so in C / C++
#define byte unsigned char
that is acceptable, where as in Visual Basic, Java? or other languages this may not be acceptable, so Scawen went the 'safe' route of just documenting the type and allowing the developer to do as needed. Although that said, maybe some languages don't allow struct { } or enum { } syntax... So I'm out of ideas for the moment but there you have it, it is what it is.
That said it is documented as far as what the types are and I am only speculating the reasons why they aren't defined.
Improved the HTML, although I still have a few warnings because of DOCTYPE and meta tags that I have not placed because I am not 100% sure how/what to do with them.
The new layout should fit well on 1024 monitor setups now. Overall it looks similar, with a few minor changes including all the small grammar/spelling errors you guys found. Becky will be happy to note I moved the pictures down the page a little, although someone with a taller resolution will likely see the top part of the pictures still, it is completely hidden at first glance on my screen in FF and IE. I also changed the ordering of the skills list to make a little more sense, I hope.
Added: A very simple Contact Page with my contact information, and a finishing picture of my adventure.
Soon to add a projects page. If you click on the current one you will get the old, crappy layout and lose the menu- so back would need to be pressed. The menu is nothing spectacular although it gets the job done. I was planning on adding small rounded edges, but decided that might be a bit of a challenge to get it lined up correctly; possible though and maybe an improvement I'll think about later as I think the square edges take away...
Thanks for your help and support with the process!
EDIT: Currently both Home and Resume go to 'different pages' with the same content...
I know my HTML skills are not the best, and that page you showed me is something I had been wishing existed for a long time!! That will help fix some of those silly issues... Also thanks for catching that error!
I managed to clean up the code a little bit, after reading that tags and attributes should be lowercase rather than uppercase - something I never knew/thought was important. I also removed some unneeded tables that I was using, I haven't quite figured out the purpose of <DIV> tags yet, but some people here seem sold on them, I have ready about them a bit more but still don't know how they useful...
In either way, the new coding is easier for me to read and maintain and is using CSS to help keep things more flexible with the overall page look. Does anyone know of a way to get text left-aligned "Blah Blah" and then some text right-aligned "Ha Ha" but both of these on the same line?
"Blah blah" "Ha ha"
Something like that so I can do my project name/ship date on the left and the dates I worked on the right - but to do this without a table? Maybe that would be a better implementation than adding tables to do what I want there. Sorry for the noob like question, but you guys have already helped quite a bit!
The radius is something I can change in my code. It just drives to where the cone is within a 2.5meter radius. I had to add the radius because with the first test when it came to some tighter turns the AI spun out and messed around trying to hit the exact spot. Though the idea of this radius thing was more of a quick way to indicate it is time to look for the next DriveTo point.
What really needs to happen is some algorithm for shifting up/down, braking and accelerating on a straight. For the moment I am on pause again while I consider my options as this is where 'intelligence' will start to come into play.
In the event of a 1 lap race, which most of my ties are in who has the fastest lap? Hint this is the reason why Head-to-Head started in the first place. When testing 1 lap races de Souza and I experienced our first tie. I made a you-tube movie of it, and its included in the TIES package. I get for longer races the user with the faster laptime is better detection than player id / connection id but best solution overall would be to compute the accurate time crossed - which would likely eliminate almost _all_ possibilities of ties because the precision would be a lot higher.
Unfortunately I can not find the replay of the one I want, although under careful examination of these replays I am no-longer sure how it is done. By putting it in slow motion it looks to be Jacko's idea might be correct although in some cases it also goes with my idea that the connection/player id also backs up the theory. Either way if someone wants some replays of ties I've found 6 of mine, although I know there was one in particular where the 'wrong' car one by a very visible distance.
Its has been my experience in the races where I've ended as a tie. I know that the other driver 'crossed the line first' but yet I was the one who 'won the race'.
Considering I _should_ have the replay I will try and dig it up, I've had several ties in my LFS career and this is the best pattern I've seen, I know that I had joined the server before the person who had placed second, which is why I was basing it on connection ID, although as mentioned it is possible it is based on Player ID (which makes more sense in the case of single player with AI).
I still don't know, from number of views it looks like most people ignore the thread. Probably because I started it in the pre-design phase and that likely was too much reading that a lot of people just started not clicking on and by habit don't any more. I also think it might be the location of the programmer forum. This could belong here or in the Off-Topic I didn't really know where to put it. But maybe you're right, and in either case I am doing this for myself more than others - it's just nice when others are interested... Thanks for your support.
Wrong - I do believe. When two racers finish at the 'exact same time' it goes by connection ID or player ID (not sure). The person who has a lower connection, or player ID will be placed above the other.
-----------------
That said I don't think this has anything to do with the resolution of the physics engine at 100hz. While we all know and can agree the physics runs at 100hz it can give exact times to 7 or 8 decimal places if designed to do so...
For instance Update 5000 car A is near finish line, and car B is a little closer but not crossing yet. Update 5100 now both cars have both crossed the finish line and their times will both read as (either 5000 or 5100 depending on the algorithm). The correct way to do this is to;
Find the time 't' at which the car crossed the line, this is independent of how fast, or slow, the physics system will run. t will be a value between 0 and 1, 0 representing the car crossed the line at PrevPos, and 1 representing NewPos. 0.5 would be directly in the center. The cars lap time would then be; 5000 + (0.01 * t); where 0.01 represents the time passed during a 100hz update. This will give you the accurate number...
LFS does not calculate this level of accuracy, I know this from some of the several ties I have had in the passed, some I've 'won' without being the 'winner'. It was clearly visible, in slow motion, that the other car crossed the line just slightly ahead.
When do you get an OOS error near the end of the replay? One of my old replays was doing that to me, on my copy of LFS which had obviously not changed. And I wonder why that would happen?
The Ai shifting will be the next step, and it shouldn't be too hard. Though that said; I am still limitting the setup to 40mph. The car went to 40mph not because the AI didn't shift, but because that was the limit I setup for it. I am quite astonished this worked the first try, with only 20 minutes of fiddling with what I completed the previous time - granted I hacked something in really quick so it is not completely appropriate! But, it is a first step!
That said I need to make the AI 'see' the DriveTo points through the visual sensor. As of now I hacked it to grab the DriveTo points through the world directly. Then I will need to look ahead and choose which point to drive towards. Currently it goes from cone to cone, as you can see it turns hard as it gets near the cone then continues on. I have a small radius around the cone. The car needs to be within 2.5 meters of the target, this will need to expand.
The primary test here was to see if the LFS layout format kept track of the object order. Meaning the first cone placed is the first DriveTo point, and so on. Currently if I was to go click in the middle to try adding another DriveTo point it would corrupt the 'ai' file and that wouldn't be good. So the tip here would be to add more DriveTo points than needed, and move them around as necessary, ALWAYS maintaining proper order and only deleting from the back if absolutely needed. But the test succeeded, and that is one less thing to worry about with the LFS to AIRS interface.
But yes, onto shifting and actually driving; which is the hard part. Do remember as I've said 100 times, competitive AI is a hope, but not the goal.
New updates for the very few people following the progress here. I have successfully completed a lap with my AI driving!! Ok, so this was just following cone after cone and keeping the car's speed to 40mph and the car doesn't even shift up yet, so that is a real problem as well... But in any situation I still have the AI driving a lap!
The only problem is that is actually the easy part. I am trying to decide whether I should work on getting the AI to go faster through this lap, or whether I should start doing my experimental stuff with the reference points.
Currently the AI doesn't shift up,(except for while waiting on the grid), shift down or do any sort of car control besides 'turn towards next cone'. So it is a pretty non-intelligent driver, but that is beside my point...
The driver went around Fern Bay Club!!!!!!!!!!!!!!!
Becky - I'm not an artist, I accepted that a long time ago. If you saw the one provided; it basically takes all the tables out (for good or bad), takes all colors away so that ALL text is black, and background is white with absolutely nothing else including the title graphic; which I agree needs improvement.
Also as a note I am not making this to be the most beautiful, fancy or otherwise next best website of the world, just looking to display information about myself, projects I worked on, projects I am working on and possibly even a few tips/tricks I stumble on along the way. I took your advice Becky and looked at wordpress. Sure by default it seems nice, as far as a blog place goes it looks great and has a lot of options. Made my own; which has a lack of complete everything so I won't post it here. Anyways I had the design I wanted but all the layouts are too damn thin and (actually that was what prompted me to learn CSS in the first place).
So I don't care much about being a web-developer, at this time. And I don't care much about making the prettiest web-site; I realize and accept that I am not an artist but I should be able to display the information in a nice way, which in my opinion the original (and current site I have up) is done in a nice fashion except I built it for 1024 and that is too wide for a 1024 setting ... Stupid me, never make that mistake again.
This stuff sucks... I remember exactly why I dislike webdesign and I wished I had stopped this site while it was still functional. Of course I could grab the code from the web and use it here but that has no CSS at all... and the current page is just broken...
For the last 3hrs I've been trying to take the page from a width of 1024 to a width of 960 as mentioned above by SamH for being the 'magical number'. After fighting with the layout for a long time, I finally decided doing it with the newly learned CSS would be best; whats funny was when starting I noticed that IE was not compatible with my site; pictures threw it off. But FF was. So now I test in both IE and FF and guess what, now IE is compatible and FF is not! Web-design... Grrr! That said I still don't have my page width down to 960 and can't quite figure out why. Course within the 100 tables I have it and the seriously shit code that I've somehow made work, there is probably a value that is keeping the page 'too wide'. I've done search and replaced all 1024s and other magical numbers that I used but still no luck...Not that I can easily tell if it is 960.
Annoying stuff, the next time I get it where I want I will stop there and fill the website with other pages of content.
While I will agree with the point that it conveys the same information; and that the html code you wrote is likely better in some aspects (especially considering you're adding alternate text for images that don't load like I should be but am not in the habit of doing . . .) So while I agree with those points I think the layout I've done is more aesthetically pleasing; at least in my opinion. It might not be a fancy layout or anything but I think it is working minus a few quirks.
My new found enjoyment with CSS is the fact that when (more like if) I decide to change the color/format of the text say for all the "Shipped Dates" I don't need to search through that file anymore, just open up the CSS file and change FONT.game_shipped { }, and voila all of those are updated. That is what gets me excited and makes this much more flexible than before.
And about the pictures being resized in html, I don't know what is so bad about this; besides the browser/rendering code will scale it down to perhaps less than desirable results. However, those images are thumbnails (probably not as obvious as it should be) that you can click on to make the original size; therefor I didn't think I needed two pictures. Although thinking about it from this perspective it makes more sense to have both copies to allow faster page loading. Since even if it is displayed as a small image all those bytes need to be transferred. So with the exception of that performance issue, and visual quality I don't understand/know whats so bad about IMG WIDTH=Xpx HEIGHT=Ypx.
Like I said, I am not a web-designer/developer and never cared much for it. I know enough to get my own things done, but probably more brute force than some would... As you probably noticed.
----------
I do thank-you for taking your time to do that, and I will use some of your more browser/user friendly ideas... By the way are you trying to sell me on the idea of making a page with limited to no layout for this style?
I am surprised, shocked... ASTONISHED that the little bit of web-development I've learned; both by myself and _ages_ ago in high-school; had not taught me the importance, usefulness or flexibility of CSS. Within the last 30 minutes I have opened a lot of doors that can make the editing of the visual / color scheme of a site with GREAT flexibility... I seriously am dumbfounded how when I took TWO classes in highschool (which would be a full year), they never mentioned the importance of CSS... Sure I had heard about it in my own learning process but figured it was more advanced than I wanted to get; pfft. This stuff is almost as easy as the HTML itself with flexibility of 100 times better!
:doh:
I have made a few adjustments, and fixed a spelling mistake. Majority of the content is the same, although I am contemplating redoing this page and moving the current project information to another page. Which would have two places where my 'work history' is; however one would be displayed more for employers and the other more for general public... I was hoping that it could be combined, but maybe Becky is right...
Any thoughts on trying to keep those combined Becky? Or do you stand by your previous points till the end? (Previous point being that the current information is not aimed at my target very well and thus could be aimed a bit better)
- Time to go add CSS to this little web-site for additional flexibility and learning purposes.