Yep, Sublime Text is great for whenever you don't want to use a full blown IDE.I can second Sublime Text.3
Yep, Sublime Text is great for whenever you don't want to use a full blown IDE.I can second Sublime Text.3
What do the stereotypical Java programmers writing C++ do wrong?
I was thinking more about C++ problems that cause things to go silently and/or randomly wrong in non-exceptional situations. Or wonderful stuff like this:That's not necessarily a good thing. Bugs are easier to fix the quicker they surface. Java programmers coding badly in C++ tend to do things that show up very quickly and easily. C++ programmers coding badly in Java tend to do things that fail very badly and silently. The severity of the problem is a lot lower, but the pain of tracking it down tends to be a lot worse. "catch (Exception e) {}" always makes me shiver with dread.
float sumOfThisLargeVector(std::vector<float> v);
I can second Sublime Text.3
Yep, Sublime Text is great for whenever you don't want to use a full blown IDE.
Has anyone here had a problem with visual studio 2013 where every time you opened it, the graphics would load very choppy and you couldn't edit your code at all?
So all you guys who use a Mac, what are some of your favorite tools? Not so much language specific IDEs, more like text editors, productivity tools, etc.
Yes. You are making a game for people to play and enjoy. The player is not your adversary. You do not need to secure anything against them.I realize that this is an incredibly amateur question but...
I am almost done with my first Unity Game. The default PlayerPrefs are notoriously insecure (a user can just edit the file to make the values whatever they want).
Ideally you would use encryption, and I still might since some Unity plugins look good. However, would something like the following be just slightly more secure:
Storing a high score in the insecure PlayerPrefs: Before saving the score, I multiply it by some number, let's say 5,356. Then, when loading, I make sure the number is divisible by 5,356 and, if not, say the save file is corrupt and load a default of 0 or something.
I assume this isn't very secure, but at least the user couldn't just edit the file. They would have to see the source code to see the modifier.
Would I be wasting my time doing this?
If the user saves 2-3 times with different scores and compares the score entries in the save files, the multiplier is pretty obvious. If you're gonna bother obfuscating the score at all, how about you do your multiplication thing, then flip some bits? (multipliedscore ^= 2863311531 for instance.) Do same thing again when reading the value. No more work for you, but would take some work to figure out.Storing a high score in the insecure PlayerPrefs: Before saving the score, I multiply it by some number, let's say 5,356. Then, when loading, I make sure the number is divisible by 5,356 and, if not, say the save file is corrupt and load a default of 0 or something.
I assume this isn't very secure, but at least the user couldn't just edit the file. They would have to see the source code to see the modifier.
Yes. You are making a game for people to play and enjoy. The player is not your adversary. You do not need to secure anything against them.
If you're saving your game state as a text file, then maybe compress it. I wouldn't bother with any further obfuscation.
If the user saves 2-3 times with different scores and compares the score entries in the save files, the multiplier is pretty obvious. If you're gonna bother obfuscating the score at all, how about you do your multiplication thing, then flip some bits? (multipliedscore ^= 2863311531 for instance.) Do same thing again when reading the value. No more work for you, but would take some work to figure out.
The way Guitar Hero 2, to give an example of a game that has leaderboards and local high scores, does it is scores are only updated to the leaderboard upon actually getting the score. There's no kind of checking to see if there's a saved score higher than the leaderboard score, because ideally, if you're uploading the score to the server every time you also save it locally, and all saved scores are final, then you're only missing to upload scores if the player suddenly disconnects from the internet for some reason.
Now, Guitar Hero 2's leaderboards are still fucked because people
but you're never getting past this anyway.
- have modded the game to give more points
- have memory edited the game to have a higher score upon saving than upon finishing the song
That's a completely different problem from what I understood and it demands a completely different solution. Protecting leaderboards is very different from 'protecting' save files.I agree with you in theory, but all of the games with Leaderboards full of obviously cheated scores bothers more people than the people who get frustrated that they can't cheat (I will support the devices games program, Google Play Games, Game Center, etc.). Also, eventually, for future games, I want to store info that enables/disables in-app purchases, but obviously my previous theory on rudimentary encryption wouldn't be enough for that anyway.
Unity uses its own thing which is almost as simple as a text file, but I don't think I can compress it because it converts to the default user settings file on whatever platform you export your project to.
That's a completely different problem from what I understood and it demands a completely different solution. Protecting leaderboards is very different from 'protecting' save files.
Ultimately, if your high score reporting amounts to your program saying 'this is my score, add it to the leaderboards' someone can easily look at your program, see how it says that, and simply do the same. Any approach that requires trusting the client is doomed to failure.
If you care deeply about the score board being accurate, there are options beyond just running the game on the server. For instance, listing only independently verified scores.
There's many of examples of this strategy in the real world. The world record for the hundred metre dash only includes times that were done publicly at track meets. It too would be a broken system if we trusted track runners to accurately report their times from solitary training.
I agree with you in theory, but all of the games with Leaderboards full of obviously cheated scores bothers more people than the people who get frustrated that they can't cheat
So all you guys who use a Mac, what are some of your favorite tools? Not so much language specific IDEs, more like text editors, productivity tools, etc.
I just got a Mac and while I got my Windows VM set up for my dev stuff there, I'm trying to get my Mac set up for dev work.
Edit: Sorry, I know its a bit off-topic but its the best place I could think of coming without starting a new thread.
If it's any consolation, the fact that anyone would care enough about your game to bother to try to cheat is a success itself. For small-scale developers, the hardest part of the path to success is getting noticed.If big time game companies can't prevent leaderboard cheating, I have no hope.
What a fantastically relevant username.Anyone can point out a good video or site that explains step by step how i can read a binary file, and write the information found into a dynamic 2D array (that is in two individual struct..)
Its some seriously fucked up shit..
That's not necessarily a good thing. Bugs are easier to fix the quicker they surface. Java programmers coding badly in C++ tend to do things that show up very quickly and easily. C++ programmers coding badly in Java tend to do things that fail very badly and silently. The severity of the problem is a lot lower, but the pain of tracking it down tends to be a lot worse. "catch (Exception e) {}" always makes me shiver with dread.
Is "catch (Exception e) {}" really an issue of C++ mindset? It seems more like an issue of lazyness that can affect someone regardless of their background. It's not like it's considered good practice to do that in C++ either.
As a Java newbie, why is it bad practice to use "catch (Exception e) {}" ?
What a fantastically relevant username.
struct Athlete
{
int number;
char name[32];
char sport[32];
char country[32];
}
struct ListAthletes
{
Athlete** athletes;
int capacityAthletes;
int nAthletes;
}
after opening the binary file
i have inside a function something like this
ListAthletes currentlist;
file.seekg(0, ios::end);
int nElement = int(file.tellg()/sizeof(ListAthletes));
currentlist.capacityAthletes = nElement;
currentlist.nAthletes = nElement;
I attribute the dynamic memory for the 2D array.
currentList.athletes = new Athlete* [nElement];
for (int i = 0 ; i < nElement ; i++)
currentList.athletes[i] = new Athlete [nElement];
I reset the binary pointer to the beginning
file.seekg(0, ios::beg);
for (int i = 0 ; i < nElement ; i++)
for (int j = 0 ; j < nElement ; j++)
{
file.read((char*) ¤tList.athletes[i][j].name, sizeof(currentList.athletes[i][j].name));
file.read((char*) ¤tList.athletes[i][j].sport, sizeof(currentList.athletes[i][j].sport));
file.read((char*) ¤tList.athletes[i][j].country, sizeof(currentList.athletes[i][j].country));
}
Hey. Don't normally post on here, but thought I'd poke my head, say hi and ask a few questions.
I'm three months into a six month placement at a mobile app developer, and it's been great, though definitely daunting at times. A friend helped me get in, as I'd only done several Microsoft night courses and hadn't a degree. At the time of going in, I'd just a very limited experience messing around with C#.
After spending my first weeks of the placement focused on creating simple service calls in WCF to either save or pull from a database, I've been moved up to also creating some of the more simple pages of their backend sites, using MVC. I'm feeling a little out of my league and I definitely have to refer to code already written by others or ask for help a lot. I'd no experience with Javascript/Jquery, and doing pagenation and other simple tasks has had me banging my head against a wall. A week in I'm starting to feel less like I'm drowning though.
I guess I wanted to drop in here, as outside of work, programming isn't something I spend a lot of time on, but as I'm enjoying my placement and starting to take things more serious, I want to try and become more involved outside of work too and put that extra effort in, so I'm not drowning in work. It's just sometimes easier said than done though, and I still find it difficult when I come home, especially as I normally have a numb head.
Just wondering what blogs, sites, podcasts, videos or other resources you guys keep up with? Also, if anyone has any stuff specifically on MVC, I'd appreciate. I've went through a lot of the easily found tutorials, but I'm curious of there're any video channels people would recommend, that go past just the starting stuff.
Apologies for the wall of text and cheers for reading.
I think he was referring to using "catch (Exception e) { }" in C++ code, not Java.
Sadly when im programming, my username fits me all too well...
.... can anyone point out of im totally not in the right path?
tags so it's easier to read. If you have a lot of code to show you can use [URL="http://pastebin.com/"]pastebin[/URL] as well.
If you give us some more information about what you want to do with your code we might be able to help.
Also when posting code use theCode:tags so it's easier to read. If you have a lot of code to show you can use [URL="http://pastebin.com/"]pastebin[/URL] as well.[/QUOTE] Basically all the information about athletes, their name, their sport, their country is found in a binary file. All in the order of the struct Athelte. I have to read the binary file. Then write the information found in it dynamically in the struct above, so i have to allocate the memory, which i guess is done by looking at out many elements are found in the binary file / sizeof(ListAthlete) .. (not sure)
so i have to allocate the memory, which i guess is done by looking at out many elements are found in the binary file / sizeof(ListAthlete) .. (not sure)
I think he was referring to using "catch (Exception e) { }" in C++ code, not Java.
As a Java newbie, why is it bad practice to use "catch (Exception e) {}" ?
try { ... } catch (DontReallyCareException e) {
// Expected behavior during initialization. No clean-up needed.
}
try { ... } catch (WhitelistedSuppressedException e) {
// Expected behavior
} catch (Exception e) {
DebugLog("Suppressed unexpected exception: " + e);
}
Normally folks would not mess with raw pointers and arrays, but use normal values, smart pointers and vectors. I presume you've been specifically told to do otherwise, and the struct definitions are a given..... can anyone point out of im totally not in the right path?
The problem with catching all exceptions is that if one of the methods in your try block changes and throws a new exception type that must be handled for correctness reasons, the generic catch block will silently suppress it. It makes your code fragile to change and difficult to debug when things go wrong.
No, I meant both languages.
Selection 1 = dec 1 / hex 1
Selection 2 = dec 2 / hex 2
Selection 3 = dec 4 / hex 4
Selection 4 = dec 8 / hex 8
Selection 5 = dec 16 / hex 10
Selection 6 = dec 32 / hex 20
Selection 7 = dec 64 / hex 40
Selection 8 = dec 128 / hex 80
Selection: Nothing = Result: dec 0 / hex 00
Selection: 1 = Result: dec 1 / hex 1
Selection: 1 & 2 = Result: dec 3 / hex 3
Selection: 1 & 2 & 6 & 8 = Result: dec 163 / hex A3
Selection: 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 = Result: dec 255 / hex FF
You've (almost) invented bit flags for yourself. Good work
Why do you want the pre-computed decimal-hex conversions? If it is to make a large switch statement, you're better off using masks to check which selections are made.
So just wondering if anyone has a quick list / spreadsheet of all the potential combinations of those 8 selections, and the asociated dec/hex values?
So just wondering if anyone has a quick list / spreadsheet of all the potential combinations of those 8 selections, and the asociated dec/hex values?
If the switch statement in whatever language you are using can only handle int constants and not expressions, you might want to consider restructuring the code to not use a switch because using raw "magic values" isn't very maintainable or good code.Do I get a cookie?
Ah, I'm doing a singular switch statement, based off the single value / masking.
I guess it's mainly for personal use / documentation (i.e. cheat sheet) as a quick sanity check? Interfacing with some hardware, so makes sense to me to have that quick double check.
Don't think it's really a problem anymore now, just wrote a quick bit of VBA to generate the possible combinations / cheat sheet. Just thought it would have been something that would be quite easy to find lying around.
If the switch statement in whatever language you are using can only handle int constants and not expressions, you might want to consider restructuring the code to not use a switch because using raw "magic values" isn't very maintainable or good code.
Or, if you only need a few combinations, you could name them and construct them before the switch. e.g. startEngineFlags = igniterFlag & discombobulatorFlag & fuelPumpFlag;
Regarding the individual flag values, they are also easier to get right if you generate them with 1 << i where i = 0...(#flags-1) instead of writing them out by hand.
Sorry, fixed. The &'s from RustyO's post somehow found their way into mine.|, presumably, not &. When dealing in bitmasks, &ing the values together is going to give 0.
I need some help with generic data types in c. I'm using the Dllist data structure from here
http://web.eecs.utk.edu/~plank/plank/classes/cs360/360/notes/Dllists/ with node type Jval here
http://web.eecs.utk.edu/~plank/plank/classes/cs360/360/notes/Jval/
The assignment I'm working on deals with multithreading junk which I'm fine with. I need to implement a list of "person" datatypes using the doubly linked list data type above but I'm not really familiar with these more generic lists(I;ve always just made a specific list for x assignment) so I'm kind of stuck on what I need to do to make a doubly linked list of people. I tried using a person variable in the append function casted to Jval for kicks but it spit out
"error: cast to union type from type not present in union dll_append(gList, (Jval) *p);"
Any tips on what I need to do/where I should look to figure it out wouldbe great.
I need some help with generic data types in c. I'm using the Dllist data structure from here
http://web.eecs.utk.edu/~plank/plank/classes/cs360/360/notes/Dllists/ with node type Jval here
http://web.eecs.utk.edu/~plank/plank/classes/cs360/360/notes/Jval/
The assignment I'm working on deals with multithreading junk which I'm fine with. I need to implement a list of "person" datatypes using the doubly linked list data type above but I'm not really familiar with these more generic lists(I;ve always just made a specific list for x assignment) so I'm kind of stuck on what I need to do to make a doubly linked list of people. I tried using a person variable in the append function casted to Jval for kicks but it spit out
"error: cast to union type from type not present in union dll_append(gList, (Jval) *p);"
Any tips on what I need to do/where I should look to figure it out wouldbe great.
person *p;
dllist gList;
...
Jval j;
j.v = (void*)p;
dll_append(gList, j)
Looks like "lets teach our students C with structs/functions that make it look like java that we taught them the last 1-2 semesters". ...
The Jval union has a void ptr v, so something like
Code:person *p; dllist gList; ... Jval j; j.v = (void*)p; dll_append(gList, j)
should work.
A dangerous assumption.The humans I can just assume that they aren't idiots and won't try to choose the same spot
The easiest way to do this is just to make two lists, one for open cells and one for closed cells. Whenever a player makes a move, take that cell out of the list of "open" cells and move it into "closed". Then have your computer just choose randomly from the list of open cells.Hey guys, so I'm in an intro to CS class (learning Java) and I was wondering if anyone could help me with a basic idea of how to set this up. I'm supposed to make a TicTacToe game with either a human and a computer player or two human players. The humans I can just assume that they aren't idiots and won't try to choose the same spot but I'm not sure how to get the computer to recognize an open spot. Spots are chosen using coordinates (ABC for the X-axis and 123 for the Y-axis).
Catch the exception and provide a default. What should the method return if the parse fails?dumb java question:
for an abstract class, im adding a new method that needs to parse stuff, which is run during the initialization method of this abstract class.
problem is i learned that im not allowed to add throw parse exception to said init method.
i feel like there is another way i can do this without java compiler being pissy but i can't think of it.
:/