Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // basic file operations
- #include <iostream>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <sstream>
- #include <iomanip>
- #include <Windows.h>
- using namespace std;
- int main ()
- {
- //===== VARIJABLE ========================================================
- ifstream input_file;//iz ovog fajla program cita
- string loaded_file;//lokacija za ucitavanje fajla
- string getlinestring;
- float change;//velicina pomjeranja
- int side = 0;//koordinata pomjeranja
- //===== PROGRAM ========================================================
- cout << "SA-MP MAP MOVER - v0.1 (Gigi Falcone)" << endl;
- cout << "=====================================================" << endl;
- cout << endl;
- cout << "Unesite koordinatu koju zelite da pomjerate, X - 1, Y - 2, Z - 3:";
- cin >> side;
- cout << "Unesite velicinu pomjeranja (Primjer: 150.0): ";
- cin >> change;
- cout << "Unesite ime fajla iz kojeg zelite da ucitate objekte: ";
- cin >> loaded_file;
- cout << "-----------------------------------------------------" << endl;
- cout << "- Ucitavanje objekata iz fajla: " << loaded_file << endl;
- string temp_loaded_file = loaded_file + ".txt";
- input_file.open(temp_loaded_file);
- string output_file = loaded_file + "_converted.txt";
- if(input_file.is_open())
- {
- int timer1 = GetTickCount();
- //varijable
- int bracketpos[2];
- int commapos[4];
- int modelid;
- string coordvar1;
- string coordvar2;
- string coordvar3;
- string reststring;
- ofstream outfile(output_file);
- //ostalo
- cout << "- Ucitavanje fajla je uspjesno, pomjeranje mape je u toku..." << endl;
- cout << "-----------------------------------------------------" << endl;
- while(getline(input_file,getlinestring))
- {
- //Prva Zagrada
- string tempstring1;
- bracketpos[0] = getlinestring.find("(");//pronalazak prve zagrade posle CreateObject ili CreateDynamicObject
- commapos[0] = getlinestring.find(",");//pronalazak prvog zareza
- tempstring1 = getlinestring.substr(bracketpos[0] + 1,commapos[0] - (bracketpos[0] + 1));//izvlacenje modela objekta izmedju zagrade "(" i prvog zareza ","
- stringstream(tempstring1) >> modelid;//konvertovanje stringa modela u broj modelid
- //Prvi Zarez
- commapos[0]++;
- commapos[1] = getlinestring.find(",",commapos[0]);
- coordvar1 = getlinestring.substr(commapos[0],commapos[1] - commapos[0]);
- double coord1 = stod(coordvar1);
- //Drugi Zarez
- commapos[1]++;
- commapos[2] = getlinestring.find(",",commapos[1]);
- coordvar2 = getlinestring.substr(commapos[1],commapos[2] - commapos[1]);
- double coord2 = stod(coordvar2);
- //Treci Zarez
- commapos[2]++;
- commapos[3] = getlinestring.find(",",commapos[2]);
- coordvar3 = getlinestring.substr(commapos[2],commapos[3] - commapos[2]);
- double coord3 = stod(coordvar3);
- //Ostatak koda do kraja reda
- bracketpos[1] = getlinestring.find(")");
- reststring = getlinestring.substr(commapos[3],bracketpos[1]);
- if(side == 1)//Koordinata X
- {
- coord1 = coord1 + change;
- }
- else if(side == 2)//Koordinata Y
- {
- coord2 = coord2 + change;
- }
- else if(side == 3)//Koordinata Z
- {
- coord3 = coord3 + change;
- }
- outfile << "CreateObject(" << modelid << "," << setprecision(9) << coord1 << "," << setprecision(9) << coord2 << "," << setprecision(9) << coord3 << reststring << "\n";
- cout << "CreateObject(" << modelid << "," << setprecision(9) << coord1 << "," << setprecision(9) << coord2 << "," << setprecision(9) << coord3 << reststring << "\n";
- }
- outfile.close();
- cout << endl;
- cout << endl;
- int timer2 = GetTickCount() - timer1;
- cout << "- Konvertovanje mape je uspjesno zavrseno!" << endl;
- cout << "Vrijeme konvertovanja: " << timer2 << "ms" << endl;
- }
- else
- {
- cout << "- Ucitavanje fajla nije uspjesno! ((fajl '" << temp_loaded_file << "' ne postoji))" << endl;
- cin.ignore();
- }
- int a;
- cin >> a;
- //printanje u fajl
- //output_file.open ("converted.pwn");
- //output_file << getlinestring << "\n";
- //output_file.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement