Shop  •   Avatar  •   FAQ  •   Search  •   Memberlist  •   Usergroups  •   Profile  •   Log in to check private messages  •   Log in  •  Register 

c++ version of savegame editor
Post new topic   Reply to topic     Forum Index -> Customization & Modding
View previous topic :: View next topic  
Author Message
jlangsdo
Cutthroat
Posts: 400



10932 Gold -

PostPosted: Mon Apr 22, 2019 3:17 pm    Post subject: c++ version of savegame editor Reply with quote

Ahoy!

It's been a long time, I'm amazed to see that this site keeps going!

I decided that I wanted to learn c++, and thought that a nice size project to learn with would be rewriting my pirates savegame editor. The perl code for it was really nasty, so a big part of this project was untangling all of that.

This new version is about 8x faster than the perl version, not that runtime was ever really much of an issue. [Also, to be fair to perl, I never ran it through the perl profiler to look for easy speedups.] One big surprise for me was that regex are really slow in c++, at least compared to string operations like find and substr.

So, here it is on github:
https://github.com/jlangsdo/pirates_savegame_editor

I wrote this in Xcode on my mac. I have no idea how to build it on another machine.

Actually, if you have a mac it looks like github makes it easy to get into Xcode, then Build->For Profiling and look for the release version in a crazily named directory:
/Users/$USER/Library/Developer/Xcode/DerivedData/pirates_savegame_editor-*/Build/Products/Release/

I should probably remove the use of 'boost' functions so you wouldn't need to install boost to make it work.

Anyone out there want to work with me to figure out porting, and we can post a README on how to install it? It would be especially useful if you run on Windows.
Back to top
View user's profile Send private message
fleetp
Boatswain
Posts: 3739



36155 Gold -

PostPosted: Mon Apr 22, 2019 5:02 pm    Post subject: Reply with quote

Holy mackerel! Welcome back!
Back to top
View user's profile Send private message Send e-mail
Pirate
Helmsman
Posts: 5589



109759 Gold -

PostPosted: Tue Apr 23, 2019 1:56 am    Post subject: Reply with quote

Welcome Back!
Back to top
View user's profile Send private message
parksbanyon
Gunner
Posts: 565



13127 Gold -

PostPosted: Fri May 17, 2019 12:24 pm    Post subject: welcome back Reply with quote

Any other winblows users out there to help with the porting? When I go thru the savegame editor I reach a "main.cpp" I can download....this should be the main body coding..?..?
Back to top
View user's profile Send private message
parksbanyon
Gunner
Posts: 565



13127 Gold -

PostPosted: Fri May 17, 2019 12:32 pm    Post subject: got i all Reply with quote

had to use firefox to get the entire download
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Wed Mar 11, 2020 2:25 am    Post subject: Reply with quote

jlangsdo wrote:
I wrote this in Xcode on my mac. I have no idea how to build it on another machine


FYI

on github for a complete download

Green Clone or download button on right - drop down arrow -
Download as a Zip link

will give you a zip file of the github link complete contents


Xcode is an integrated development environment (IDE) that consists of set of software development tools which are designed by Apple specifically for developing software on Mac OS X and iOS.

The app development kit, Xcode is not available for any other operating systems except Mac OS X and iOS.

To run Xcode on a Windows PC requires an Apple OSX Virtual machine
with an Xcode installation and not a trival install.

This article gives an overview of what is involved
https://www.alltechbuzz.net/install-xcode-on-windows-for-ios-sdk/

Even then it will not produce a native Windows executable


Youtube clip
How to Install xcode on Windows | How to use Swift Compiler on Windows
https://www.youtube.com/watch?v=F8UKtjPEiWA

Warning - Indian accented English, may find it difficult to follow


This is what Microsoft has to say For Visual Studio, for example

Import an Xcode project
https://docs.microsoft.com/en-us/cpp/cross-platform/import-an-xcode-project?view=vs-2019

The Visual Studio tools for cross-platform mobile development with C++ include support for moving your Xcode projects into Visual Studio, where you can create cross-platform libraries and share code with other projects.

Rule of thumb appears to be Xcode for Apple apps, and Visual Studio or others for Windows apps.


Microsoft is not the only Retail Sold C++ Complier for Windows,
for example

Intel® C++ Compiler
https://software.intel.com/en-us/c-compilers
Evaluation Trial version available


An opensource GCC compiler maybe an option
(dependancies dependent, and Windows probably requires coding
changes to say OSX at a guess)
A GCC compiler is included in most Linux Distributions but not with Windows, available via 3rd party downloads.


mingw - Windows version of GCC.
http://www.mingw.org/
or
http://www.cygwin.com/
a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.
Includes a GCC Compiler.


A GCC Compler is available for Apple Xcode but not installed by default

gcc compiler on Mac OS X
https://mkyong.com/mac/how-to-install-gcc-compiler-on-mac-os-x/

Mac OS X: Install GCC Compiler with Xcode
https://www.cyberciti.biz/faq/howto-apple-mac-os-x-install-gcc-compiler/


At a guess, Xcode C++ source run through the Apple Xcode - GCC compiler, may have a better chance of working with a Windows PC GCC compiler.



Integrated development environment (IDE) alternatives
for Windows to Xcode.
https://alternativeto.net/software/xcode/?platform=windows


Last edited by corsair91 on Tue Oct 13, 2020 2:50 am; edited 14 times in total
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Wed Mar 11, 2020 7:06 pm    Post subject: Reply with quote

More links

Some content may now be outdated


Integrated Development Environments (IDE) for Minigw

GCC Complier is a command line compiler
unless you sort out an IDE for it.


http://www.mingw.org/wiki/ide

http://www.codeblocks.org/
free C, C++ and Fortran IDE

http://www.bloodshed.net/devcpp.html
Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler. Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler.


Visual-MinGW
https://sourceforge.net/projects/visual-mingw/

Development of a visual IDE for MinGW


MinGW Developer Studio
http://vaultec.mbnet.fi/mingwstudio.php

Cross-platform C/C++ IDE (Integrated Development Environment) for MinGW compiler system. MinGW Developer Studio is designed to look and feel like MS Visual C++ 6.0.



Setting up the MinGW compiler and Text Editor,
(Notebook Plus Freeware Editor in this example)

https://subscription.packtpub.com/book/networking_and_servers/9781785283079/1/ch01lvl1sec08/setting-up-the-mingw-compiler-and-text-editor



MinGW-w64 - for 32 and 64 bit Windows
https://sourceforge.net/projects/mingw-w64/

The mingw-w64 project is a complete runtime environment for gcc to support binaries native to Windows 64-bit and 32-bit operating systems.
http://mingw-w64.org/

Darwin/OSX version
http://mingw-w64.org/doku.php/download/darwin


Last edited by corsair91 on Fri Mar 13, 2020 12:16 am; edited 2 times in total
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Thu Mar 12, 2020 7:58 pm    Post subject: Reply with quote

Since this is based on a perl script

pirates_savegame_editor.pl
Converts a savegame file to a readable and editable text file and back

(the script includes the options syntax in the script remarks)


link to jlangsdo's mods
http://www.hookedonpirates.com/forums/viewtopic.php?t=7705


another possible alternative

(with some reservations such as level of performance and
size of executable generated,
as Perl is an Interpreted Script and rewriting in say C++
is one of the frequently recommended performance improvements)


is convert the perl script to a windows excutable

(may need to have the perl environment, added to to windows Path system
variable, when generating the executable)


A Google search on say
convert perl script to windows excutable
should give some hits

EDIT: Perl2exe with Stawberry perl,
generating a executable from the Perl script is less than
5 MB in size and no real performance advantage over running the script
natively from Perl. Still needs to run in the Windows command line.

(Strawberry perl takes care of setting the windows environmenal path as part of the install)


Options suggested appear to depend on What Windows Perl Distribution you have.


Checking out
https://www.perl.org/
https://www.perl.org/get.html#win32

suggests 2 Perl Distribution options - activeperl and strawberryperl


activeperl
http://www.activestate.com/activeperl/downloads
(may require a user account)

strawberryperl
http://strawberryperl.com/


A Beginner’s Guide to Compiling Perl Scripts
https://www.marcbilodeau.com/compiling-perl/


Reading around some, this is what tended to be recommended
for each perl distribution.


activeperl

Perl2exe
http://www.indigostar.com/perl2exe/

Perl2Exe is a command line program for converting Perl scripts to executable files.
Specific version of Perl required, has a link for Strawberry Perl

This allows you to create stand alone programs in Perl that do not require the Perl interpreter

All downloads are free non-expiring trial versions.
Non-trial features can be activated when a licence is purchased
Windows versions of Perl2Exe require a Perl interpreter
Trial version may have watermarking on the output and license
limitations on distributing executables.

EDIT: see the next post for confirmation on this


strawberryperl

Converting .pl to .exe file
https://www.perlmonks.org/?node_id=1115026

recommend installing the PAR::Packer module, which would give you the pp utility

https://metacpan.org/pod/PAR::Packer

PAR-Packer Module
https://metacpan.org/pod/PAR

PAR-Packer download
https://github.com/rschupp/PAR-Packer

https://metacpan.org/pod/pp

This utility can bundle your script into a stand-alone executable. The documentation for pp does include some examples.


PAR::Packer module may also work with activeperl


Some Perl distributions may have perlcc included (outdated),
run your perl code through a c compiler to make an executable.
strawberryperl does included a GCC complier.



parksbanyon posted this useful Perl on windows link previously

using PERL with windows a linked article
http://www.hookedonpirates.com/forums/viewtopic.php?t=6662


How do I make my Perl scripts act like normal programs on Windows?

https://stackoverflow.com/questions/4727480/how-do-i-make-my-perl-scripts-act-like-normal-programs-on-windows


Last edited by corsair91 on Thu Dec 07, 2023 9:06 pm; edited 26 times in total
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Thu Mar 12, 2020 8:19 pm    Post subject: Reply with quote

Perl2Exe User Manual
http://www.indigostar.com/pxman.html

Exe files generated by the registered version of Perl2exe may be freely distributed.
$149 US Single User License


Shareware Version

You are hereby licensed to use the shareware evaluation version of Perl2Exe for evaluation purposes without charge for a period of 30 days. This is not free software. If you use this software after the 30 day evaluation period a registration fee is required. Under no circumstances are you licensed to distribute Exe files created by the shareware evaluation version of Perl2Exe. Unregistered use of Perl2Exe after the 30 day evaluation period is in violation of copyright laws.
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Fri Mar 13, 2020 5:13 pm    Post subject: Reply with quote

If you install say a GCC Complier or Perl distribution on Windows,
you may have to add the install location to the Windows System path.

This is best done by this procedure using Control Panel
as the Tablet style - Settings App doesn't have this functionality
in Windows 10 1909.


Setting global environment variables on Windows

https://support.shotgunsoftware.com/hc/en-us/articles/114094235653-Setting-global-environment-variables-on-Windows

November 15, 2019

EDIT: Link now appears dead



https://knowledge.autodesk.com/support/shotgrid/learn-explore/caas/CloudHelp/cloudhelp/ENU/SG-RV/files/rv-knowledge-base/SG-RV-rv-knowledge-base-rv-setting-global-variables-windows-html-html.html#:~:text=Right%20click%20the%20Computer%20icon,to%20edit%2C%20and%20click%20Edit.



Windows 10 and Windows 8

Search and select System (Control Panel).

Click on the Advanced system settings link
and then click Environment Variables.
Under the section System Variables, select the environment variable you want to edit, and click Edit.

If the environment variable you want doesn't exist, click New.
Input the value of the environment variable in the Edit System Variable (or New System Variable) window, and click OK.


Windows 7

Right click the Computer icon on your desktop and choose Properties from the menu.
Click on the Advanced system settings link and then click Environment Variables. Under the section System Variables, select the environment variable you want to edit, and click Edit.
If the environment variable you want doesn't exist, click New.
Input the value of the environment variable in the Edit System Variable (or New System Variable) window, and click OK.


EDIT:
Strawberry Perl apparently takes care of setting the windows environmenal path as part of the install


Last edited by corsair91 on Sat Nov 20, 2021 10:11 pm; edited 4 times in total
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Mon Mar 16, 2020 6:37 pm    Post subject: Reply with quote

If you need a savegame for testing, this may help


Sid Meier Pirates Savegame

https://savesforgames.com/
https://savesforgames.com/game-saves/save-for-sid-meiers-pirates/


Savegame for Sid Meier’s Pirates!
– The game done 100%

– Your character – a married Duke, which owns all countries
– All the pirates are destroyed
– All treasures found
– All the relatives found
– You counts about 500,000 coins

Installation:
Copy files from archive to game_dir

Download link
https://savesforgames.com/wp-content/uploads/2017/files/sid-meiers-pirates.rar


Pirates! Savegame location
C:\Users\my profile name\Documents\My Games\Sid Meier's Pirates!


Last edited by corsair91 on Tue Oct 13, 2020 3:16 am; edited 4 times in total
Back to top
View user's profile Send private message
Pirate
Helmsman
Posts: 5589



109759 Gold -

PostPosted: Tue Mar 17, 2020 1:02 am    Post subject: Reply with quote

Why would anyone be needing a completed game for unless maybe they think it might could gather information in it to cheat or something.
Back to top
View user's profile Send private message
fleetp
Boatswain
Posts: 3739



36155 Gold -

PostPosted: Tue Mar 17, 2020 7:29 pm    Post subject: Reply with quote

Pirate wrote:
Why would anyone be needing a completed game for unless maybe they think it might could gather information in it to cheat or something.


I was thinking the same thing.
Back to top
View user's profile Send private message Send e-mail
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Tue Oct 13, 2020 2:43 am    Post subject: Reply with quote

Stumbled over these Windows Shell extensions

May be helpful when using perl scripts


Freeware Utilities
https://www.4dots-software.com/free-software/

Windows 10 supported


Open Command Prompt Here
https://www.4dots-software.com/open-command-prompt-here/


Run programs with arguments directly from Windows Explorer
https://www.4dots-software.com/runwithparameters/
Back to top
View user's profile Send private message
corsair91
Sailing Master
Posts: 8266



208036 Gold -

PostPosted: Mon Mar 13, 2023 4:19 pm    Post subject: Reply with quote

Stumbled over this

(Xcode is the included Apple Mac development environment.

Unlike Linux, there is no included Windows OS Development environment
as requires 3rd party freeware downloads or $ commercial products.)


Xcode Plugin for Win32 c/c++ compiler
http://pbil.univ-lyon1.fr/members/mgouy/XCodeWin32Plugin/


Win32Plugin gives Xcode, Apple's development environment, the possibility to fully drive a GNU c/c++ cross-compiler for MS Windows (95 and above). Win32Plugin works with versions 2.5, 3.1.*, and 3.2 of Xcode.


Win32Plugin allows a single Xcode project to build executables for MacOS X and MS Windows platforms.


see link for further info

---------------------------

Some Xcode Info

Xcode Through the Years
https://martiancraft.com/blog/2022/01/xcode-through-the-years/

How to use Xcode for C and C++ development
https://wpguru.co.uk/2017/06/how-to-use-xcode-for-c-and-c-development/

Developing C programs on Mac OS (using Xcode)
https://www.cs.auckland.ac.nz/~paul/C/Mac/xcode/

Developing C programs on Mac OS
https://www.cs.auckland.ac.nz/~paul/C/Mac/

Xcode install (on MacOS)
https://wilsonmar.github.io/xcode/

Mac OS X: Install GCC Compiler with Xcode
https://www.cyberciti.biz/faq/howto-apple-mac-os-x-install-gcc-compiler/

Compiling in MacOS X
https://osupdocs.forestry.oregonstate.edu/index.php/Compiling_in_MacOS_X

---------------------------

Some Generic Info

C Programming/What you need before you can learn
https://en.wikibooks.org/wiki/C_Programming/What_you_need_before_you_can_learn

How to Learn C and C++ Programming: The Ultimate Resource List
https://www.toptal.com/c/the-ultimate-list-of-resources-to-learn-c-and-c-plus-plus

Best C++ IDEs
https://www.udacity.com/blog/2020/05/best-c-ides.html

Installing a C++ Compiler on Your Own PC
https://www.cs.odu.edu/~zeil/cs250PreTest/latest/Public/installingACompiler/

Catching silly mistakes with GCC
https://codeforces.com/blog/entry/15547
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Customization & Modding All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group