Checking out Earth in the solar system builder |
Manually loading member data |
Captain list |
Another thing I came across was an interesting piece of code that will not compile anymore. You can tell it was written in a time when you could overwrite memory with no protection. It was the code that replaced a tilde (~) with a string you passed it. The original code looked like this...
cs = strchr(ts,'~');
if(cs != NULL) {
*cs = 0;
strcpy(bs,ts);
*cs = '~';
cs++;
strcat(bs,s);
strcat(bs,cs);
}
*cs = 0;
strcpy(bs,ts);
*cs = '~';
cs++;
strcat(bs,s);
strcat(bs,cs);
}
else strcpy(bs,ts);
You just can't arbitrarily change data at a pointer that's pointing to... something anymore. [*cs = 0;] - Windows gets super upset when you try. It was fixed with a little pointer math like such.
cs = strchr(ts, '~');
if (cs != NULL) {
n = cs - ts; //n = characters from ts to cs
memcpy(bs, ts, n); //copy up to cs into bs
bs[n] = '\0'; //terminate the string
cs++; //push the pointer up one to skip the tilde
strcat(bs, s); //cat "file" to bs
strcat(bs, cs); //cat the rest of the string to bs.
}
else strcpy(bs, ts);
You have to be polite as ask to do things with memory as opposed to plopping a pointer anywhere you want.
Anywho, Here's a few final screenshots of progress.
Sol System - HD circle on radar screen |
Captain Dossier |
No comments:
Post a Comment