Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / tools / sheets_packer / sheets_packer.cpp
blob25e53b57cbfa887453b2c407dd5af376c5bda40a
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //////////////
21 // INCLUDES //
22 //////////////
23 #include "stdpch.h"
25 // Application
26 #include "sheets_packer_cfg.h"
27 #include "sheet_manager.h"
28 #include "continent_manager_build.h"
31 ///////////
32 // USING //
33 ///////////
34 using namespace NLMISC;
37 /////////////
38 // GLOBALS //
39 /////////////
40 NLLIGO::CLigoConfig LigoConfig;
43 ///////////////
44 // FUNCTIONS //
45 ///////////////
48 //---------------------------------------------------
49 // MAIN :
50 // Entry for the Apllication.
51 //---------------------------------------------------
52 int main(int argc, char **argv)
54 CApplicationContext applicationContext;
56 // Parse Command Line.
57 NLMISC::CCmdArgs args;
59 args.setDescription("Pack all sheets needed by client. All parameters must be defined in sheets_packer.cfg and there is no parameters from command-line.");
61 if (!args.parse(argc, argv)) return 1;
63 CFileDisplayer *fd = NULL;
65 /////////////////////////////////
66 // Initialize the application. //
67 try
69 // Add a displayer for Debug Infos, disable log.log.
70 createDebug(NULL, false);
72 CLog::setProcessName("sheets_packer");
74 fd = new CFileDisplayer(getLogDirectory() + "sheets_packer.log", true, "SHEETS_PACKER.LOG");
76 // register ligo 'standard' class
77 NLLIGO::Register();
79 DebugLog->addDisplayer(fd);
80 InfoLog->addDisplayer(fd);
81 WarningLog->addDisplayer(fd);
82 ErrorLog->addDisplayer(fd);
83 AssertLog->addDisplayer(fd);
85 // Load the application configuration.
86 nlinfo("Loading config file...");
87 AppCfg.init(ConfigFileName);
89 // Define the root path that contains all data needed for the application.
90 nlinfo("Adding search paths...");
91 for (uint i = 0; i < AppCfg.DataPath.size(); i++)
92 CPath::addSearchPath(NLMISC::expandEnvironmentVariables(AppCfg.DataPath[i]), true, false);
94 // Initialize Sheet IDs.
95 nlinfo("Init SheetId...");
96 CSheetId::init(true);
98 // load packed sheets
99 nlinfo("Loading sheets...");
100 IProgressCallback callback;
101 SheetMngr.setOutputDataPath(NLMISC::expandEnvironmentVariables(AppCfg.OutputDataPath));
102 SheetMngr.load(callback, true, true, AppCfg.DumpVisualSlotsIndex);
104 // Make the lmconts.packed file
105 if (!LigoConfig.readPrimitiveClass(AppCfg.LigoPrimitiveClass.c_str(), false))
106 nlwarning("Can't load primitive class file %s", AppCfg.LigoPrimitiveClass.c_str());
107 NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
108 buildLMConts(AppCfg.WorldSheet, NLMISC::expandEnvironmentVariables(AppCfg.PrimitivesPath), NLMISC::expandEnvironmentVariables(AppCfg.OutputDataPath));
110 catch(const EFatalError &) { return EXIT_FAILURE; /* nothing to do */ }
111 catch(const Exception &e)
115 nlerror ("Initialization of the application failed : %s", e.what());
117 catch(const EFatalError &)
119 // nothing to do
122 // Failure -> Exit.
123 return EXIT_FAILURE;
126 /////////////////////////////
127 // Release all the memory. //
130 DebugLog->removeDisplayer("SHEETS_PACKER.LOG");
131 InfoLog->removeDisplayer("SHEETS_PACKER.LOG");
132 WarningLog->removeDisplayer("SHEETS_PACKER.LOG");
133 ErrorLog->removeDisplayer("SHEETS_PACKER.LOG");
134 AssertLog->removeDisplayer("SHEETS_PACKER.LOG");
136 if (fd) delete fd;
137 fd = NULL;
139 catch(const EFatalError &) { return EXIT_FAILURE; /* nothing to do */ }
140 catch(const Exception &e)
144 nlerror ("Release of the application failed: %s", e.what());
146 catch(const EFatalError &)
148 // nothing to do
151 // Failure -> Exit.
152 return EXIT_FAILURE;
156 // EXIT of the Application.
157 return EXIT_SUCCESS;
158 }// main //