Ferrous Moon
http://www.ferrousmoon.com:80/forums/

OnlinkLogNuker
http://www.ferrousmoon.com:80/forums/viewtopic.php?f=52&t=2003
Page 1 of 2

Author:  Coder [Sun May 02, 2010 11:45 am ]
Post subject:  OnlinkLogNuker

I noticed that the onlink game is always lack of memory. In some previous post, I guessed this is because of the action without a mission, finally I discover it's because of the lack of memory. Why onlink need so many memory? I think it's because of the huge amount of logs. To gain more time before the server disconnect you, you must bounce as many nodes as possible. And to crack the ACS, you need at least 40 clients online. The "40" is derived from my imagination, now there is 36 clients on line, I still can't DDos the ACS. This cause the log information occupy more than 80% of the save file while I don't think they are useful. So I write a program to erase log from your save file. The memory before I do this used by onlink is 240MB while 75MB after I erasing logs. The code below is just for me, and you should change the filename and recompile it.
Code:
#include <cstdio> #include <cstdlib> #include <string.h> #define BUFFER_SIZE 4096 char buffer[BUFFER_SIZE]; char token[BUFFER_SIZE + 1]; int lookAhead; int bufferPos; int bufferLen; int nextChar(FILE *file){ if (bufferPos == bufferLen){ bufferLen = fread(buffer, 1, BUFFER_SIZE, file); if (bufferLen <= 0) return -1; bufferPos = 0; } return buffer[bufferPos++]; } void readUntil(FILE *file, char *buf, int &nowAt, char targetCh){ bool inStr = false; lookAhead = nextChar(file); while ((lookAhead != targetCh) || inStr){ buf[nowAt++] = lookAhead; if (lookAhead == '"') inStr = !inStr; lookAhead = nextChar(file); if (lookAhead < 0) return; } } void nextToken(FILE *file){ int nowAt = 0; token[nowAt++] = lookAhead; if (lookAhead == '<'){ readUntil(file, token, nowAt, '>'); token[nowAt++] = lookAhead; lookAhead = nextChar(file); } else readUntil(file, token, nowAt, '<'); token[nowAt] = '\0'; } bool beginWith(char *str, char *head){ int len = strlen(head); if (strlen(str) < len) return false; for (int i = 0; i < len; i++) if (str[i] != head[i]) return false; return true; } bool endWith(char *str, char *tail){ int len = strlen(tail); int slen = strlen(str); if (slen < len) return false; for (int i = 0; i < len; i++) if (str[slen - i - 1] != tail[len - i - 1]) return false; return true; } void printLogbankHead(char *head, FILE *file){ int i = 0; while (head[i] != ' '){ fprintf(file, "%c", head[i]); i++; } fprintf(file, " count=\"0\" "); do{ i++; } while (head[i] != ' '); i++; while ((head[i] != '/') && (head[i] != '>')){ fprintf(file, "%c", head[i]); i++; } fprintf(file, "/>"); } int main(){ FILE *xmlFile = fopen("E:/Coder.xml", "r"); FILE *outputFile = fopen("E:/Coder.output.xml", "w"); bufferPos = 0; bufferLen = 0; lookAhead = nextChar(xmlFile); while (lookAhead >= 0){ nextToken(xmlFile); if (beginWith(token, "<logbank ")){ printLogbankHead(token, outputFile); if (!endWith(token, "/>")) do{ nextToken(xmlFile); }while(strcmp(token, "</logbank>")); } else fprintf(outputFile, "%s", token); } fclose(xmlFile); fclose(outputFile); }
PS: You will also need a gun zip tool to zip and unzip the save files.

Author:  skyblownet [Sun May 02, 2010 2:48 pm ]
Post subject:  Re: OnlinkLogNuker

Good job.
Just one thingy, you didn't had to write your own string 'searching/manipulating' methods.
If you'd just search for a(n) XML parse, you would have solved about 90% of the 'problem'.

skyblownet.

Author:  hans henrik [Wed May 05, 2010 5:05 am ]
Post subject:  Re: OnlinkLogNuker

i guess this will fuck up some missions, however if it doesn't fuck up storyline missions.. (devs reply?)

also i guess you could do like
Code:
int main(int argc, char* argv[]){ if (argc != 3) { printf("\nusage:\n");printf(argv[0]);printf("\"input file\" \"output file\""); return 1; } FILE *xmlFile = fopen(argv[1], "r"); FILE *outputFile = fopen(argv[2], "w");
or something..

//haven't spell checked

Author:  Tycho [Thu May 06, 2010 1:51 am ]
Post subject:  Re: OnlinkLogNuker

Yeah, this code would screw up all sorts of missions.

Author:  bioshacker001 [Thu May 06, 2010 11:37 am ]
Post subject:  Re: OnlinkLogNuker

a note on the first file. i compiled it and ran it, and it had an error. my guess is that u need to have the file in a certain location. can this be verified?

Author:  bioshacker001 [Tue May 11, 2010 12:23 pm ]
Post subject:  Re: OnlinkLogNuker

and the second cant be compiled. check the printf command.

Author:  bioshacker001 [Tue May 11, 2010 12:24 pm ]
Post subject:  Re: OnlinkLogNuker

of course, it might be that i only tried c and c++.

Author:  hans henrik [Thu May 13, 2010 9:30 am ]
Post subject:  Re: OnlinkLogNuker

Quote:
a note on the first file. i compiled it and ran it, and it had an error. my guess is that u need to have the file in a certain location. can this be verified?
Code:
FILE *xmlFile = fopen("E:/Coder.xml", "r"); FILE *outputFile = fopen("E:/Coder.output.xml", "w");
verified. need to be in "E:\Coder.xml"
thats what i tried to fix with my first post

Quote:
and the second cant be compiled. check the printf command.
it compiles for me.. what errors do you get?

Author:  bioshacker001 [Thu May 13, 2010 12:32 pm ]
Post subject:  Re: OnlinkLogNuker

the whole line is red, and it says that a variable is undefined? i dont have my flash drive with the compiler on it, so i cant check right now. i'll test it asap.

Author:  Coder [Fri May 14, 2010 1:15 am ]
Post subject:  Re: OnlinkLogNuker

Quote:
The code below is just for me, and you should change the filename and recompile it.
Please read the words above the code first.

There are two files, one is the profile save file, another is the output file, which is a new save file without any logs. The save file is saved at %HOME%/AppData/Romans/Onlink/%UserName%/%UserName%.tar.gz.

You should first unzip it to certain location, and change the file location in the
Code:
FILE *xmlFile = fopen("E:/Coder.xml", "r");
to the location you just unzipped.
Then set your output file location in
Code:
FILE *outputFile = fopen("E:/Coder.output.xml", "w");
to your destination output location.

For example: If you unzip the save file to "C:/abc/aaa.xml" and you want the new save file without logs to "D:/cba/aaa.xml", then the code will be
Code:
FILE *xmlFile = fopen("C:/abc/aaa.xml", "r"); FILE *outputFile = fopen("D:/cba/aaa.xml", "w");
Remember, you need to recompile the code, and you need to zip the new save file to replace the gzip file in the save directory.

Author:  bioshacker001 [Fri May 14, 2010 12:25 pm ]
Post subject:  Re: OnlinkLogNuker

k. thx.

Author:  bioshacker001 [Wed May 19, 2010 12:05 pm ]
Post subject:  Re: OnlinkLogNuker

heres a printscreen :
of the compiling error

Attachments:
compilererror.doc [120.5KiB]
Downloaded 655 times

Author:  Miah [Thu May 20, 2010 1:37 am ]
Post subject:  Re: OnlinkLogNuker

A printscreen? Placed in a .doc?

What's wrong with you?

Author:  bioshacker001 [Thu May 20, 2010 11:11 am ]
Post subject:  Re: OnlinkLogNuker

i cant find the system clipboard folder to be able to cut it from there and put it on the site.

Author:  FinalWarrior [Thu May 20, 2010 12:26 pm ]
Post subject:  Re: OnlinkLogNuker

Print Screen.

Open Paint (or any other image editing program).

Control-V.

Save as .jpg, .png, or any other reasonable image format.

Upload in a post (which you are already capable of, it seems).

I fail to understand how you could manage to printscreen into a .doc but not into a .jpg or a .png. The process for either is identical except for the program you open up to paste into.

-- Griffinhart

Page 1 of 2 All times are UTC-05:00
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/