diff --git a/.gitignore b/.gitignore index 1d7b8efd4..22089c19f 100644 --- a/.gitignore +++ b/.gitignore @@ -142,7 +142,6 @@ moc_*.cpp *.cache *.patch *.7z -3rdParty .svn thumbs.db Thumbs.db @@ -160,7 +159,7 @@ code/build/* code/build-2010/* build/* install/* -build_vc* +build_* code/nel/tools/build_gamedata/configuration/buildsite.py # Linux nel compile diff --git a/.hgtags b/.hgtags index 6a404b346..38ed6cd84 100644 --- a/.hgtags +++ b/.hgtags @@ -1,16 +1,27 @@ -950d650ca92e6041611258d7e5131ccf661e4ec2 compatibility-merge -4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 ryzomcore/v0.8.0 -00d9b6e29e95f56785fbf85abe60afd34674f402 ryzomcore/v0.9.0 -79776c337176dd5b02e1a74fe5dfb703b91747aa ryzomcore/v0.9.1 -fedf2aa443d09707beed814b0f499c6a5519cc84 ryzomcore/v0.10.0 -edaa3624a56420b02ccc64c26059801a389927ee ryzomcore/v0.11.0 -e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1 -9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2 -bfe5628e14a024ba7ea32e4b326ae433a07856b9 ryzomcore/v0.11.3 -9a6120735daa97c96ac5d85ca35c7f21f607bd87 ryzomcore/v0.12.0 -3e17907af67e8d66d80e6b714707bbf912607f2a ryzom-patch-3.0.0 -153e0b605c9e0c83ba05b6428c62838b49cc84b2 ryzom-patch-3.0.1 -4300cc14aad098b1f86ea4c55577b7fa4a4cb5d2 ryzom-patch-3.1.0 -043aaeb3d8a2a54177581b57bda87a9deaad510e ryzom-patch-3.1.0-april_patch -00dde390a394fce9da06c2f3264140282158d39f 3.3.0 -dcd4c4d161ef775136e18c7e8f5072b75dede27e ryzom-patch-3.3.1 +4eddbaff0c5e5d685db96ee3e8427aa0fd96ac83 v0.8.0 +00d9b6e29e95f56785fbf85abe60afd34674f402 v0.9.0 +79776c337176dd5b02e1a74fe5dfb703b91747aa v0.9.1 +fedf2aa443d09707beed814b0f499c6a5519cc84 v0.10.0 +edaa3624a56420b02ccc64c26059801a389927ee v0.11.0 +e3fe4855f22c3e75722e015dc33c091c340b3ad7 v0.11.1 +9e583b717fd63be0be9fd60b99087abf1691ea49 v0.11.2 +bfe5628e14a024ba7ea32e4b326ae433a07856b9 v0.11.3 +9a6120735daa97c96ac5d85ca35c7f21f607bd87 v0.12.0 +3e92c7104c20d6bc6c2147b4b5fc289e8621d322 v1.0.0 +8eb94c3549be898fdc4a7c6d791d2477bdc11a18 v1.0.1 +3e17907af67e8d66d80e6b714707bbf912607f2a ryzom/3.0.0 +153e0b605c9e0c83ba05b6428c62838b49cc84b2 ryzom/3.0.1 +9d41f2994d44b9aad92b83f945f114e4b6bed44a ryzom/3.0.2 +4300cc14aad098b1f86ea4c55577b7fa4a4cb5d2 ryzom/3.1.0 +d4060f217f4f834cc62a33f2f1ccdf3c28298066 ryzom/3.1.0-hotfix +043aaeb3d8a2a54177581b57bda87a9deaad510e ryzom/3.1.0-april_patch +4036ecf59e83960f03acebc2089eb2ff5eeaed0a ryzom/3.2.0 +18403bb9485da3d9742c6f007a16d5619ebfb196 ryzom/3.2.1 +822ff8f8917ad66e09e2c21c983282f6f693b9f6 ryzom/3.3.0 +00dde390a394fce9da06c2f3264140282158d39f ryzom/3.3.0 +dcd4c4d161ef775136e18c7e8f5072b75dede27e ryzom/3.3.1 +fc4be8ebec5ca754ef4453bc6a9faef90837c674 ryzom/3.4.0 +70eba02e8eab6920586dbabf74e9e8180c729980 ryzom/3.4.0-steam_fix +3941482843f9cd130cfc16634efc08d34a98ed35 ryzom/3.4.0-atysmas +ecae9feb4cceb78103e5d7236caccaf450796cdb ryzom/3.5.0 +95783afa226f241062134eb62f4323295d29ac84 ryzom/3.5.0.9637 diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..0ad25db4b --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6e0f2b2a7..0e8396061 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,5 +1,6 @@ jobs: - job: ubuntu16 + timeoutInMinutes: 120 pool: vmImage: 'Ubuntu-16.04' steps: @@ -12,20 +13,27 @@ jobs: sudo apt-get install gcc-8 g++-8 -y sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 60 - sudo apt-get install libmysqlclient-dev -y sudo apt-get install bison autoconf automake -y - sudo apt-get install libpng12-dev libjpeg62-dev -y + sudo apt-get install libpng12-dev -y + sudo apt-get install libjpeg-dev -y + sudo apt-get install libgif-dev libfreetype6-dev -y + sudo apt-get install freeglut3-dev -y sudo apt-get install liblua5.1-dev libluabind-dev libcpptest-dev -y sudo apt-get install libogg-dev libvorbis-dev libopenal-dev -y - sudo apt-get install libgif-dev libfreetype6-dev -y + sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libswscale-dev libpostproc-dev -y + sudo apt-get install libmysqlclient-dev -y sudo apt-get install libxml2-dev -y - sudo apt-get install libcurl4-openssl-dev -y + sudo apt-get install libcurl4-openssl-dev libssl-dev -y + sudo apt-get install libsquish-dev -y + sudo apt-get install liblzma-dev -y + sudo apt-get install libgsf-1-dev -y + sudo apt-get install qtbase5-dev qttools5-dev qttools5-dev-tools displayName: 'Dependencies' - script: | mkdir build cmake --version cd build - cmake -DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF ../code + cmake -DWITH_STATIC=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_CLIENT=ON -DWITH_RYZOM_TOOLS=ON -DWITH_NEL_TOOLS=ON -DWITH_NELNS=ON -DWITH_NELNS_LOGIN_SYSTEM=ON -DWITH_NELNS_SERVER=ON -DWITH_QT5=ON -DWITH_LIBGSF=ON ../code cat CMakeCache.txt displayName: 'CMake' - script: | diff --git a/code/.clang-format b/code/.clang-format new file mode 100644 index 000000000..e407c68c5 --- /dev/null +++ b/code/.clang-format @@ -0,0 +1,24 @@ +--- +BasedOnStyle: WebKit +AllowShortFunctionsOnASingleLine: All +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false +BreakBeforeBraces: Custom +BreakConstructorInitializersBeforeComma: 'false' +NamespaceIndentation: None +PointerAlignment: Right +SortIncludes: 'false' +TabWidth: '4' +UseTab: ForIndentation + +... diff --git a/code/.editorconfig b/code/.editorconfig new file mode 100644 index 000000000..e4aef2c53 --- /dev/null +++ b/code/.editorconfig @@ -0,0 +1,23 @@ +; Top-most EditorConfig file +root = true + +; 4-column tab indentation +[*.cpp] +indent_style = tab +indent_size = 4 + +[*.c] +indent_style = tab +indent_size = 4 + +[*.h] +indent_style = tab +indent_size = 4 + +[*.py] +indent_style = tab +indent_size = 4 + +[*.config] +indent_style = space +indent_size = 2 diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 681f7a959..31554fac4 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -48,15 +48,15 @@ CHECK_OUT_OF_SOURCE() IF(CMAKE_VERSION VERSION_GREATER "2.8.10") STRING(TIMESTAMP CURRENT_YEAR "%Y") ELSE() - SET(CURRENT_YEAR "2016") + SET(CURRENT_YEAR "2019") ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) SET(NL_VERSION_MAJOR 1) SET(NL_VERSION_MINOR 0) -SET(NL_VERSION_PATCH 0) -SET(YEAR "2004-${CURRENT_YEAR}") +SET(NL_VERSION_PATCH 2) +SET(YEAR "2001-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") #----------------------------------------------------------------------------- @@ -92,6 +92,29 @@ NL_SETUP_BUILD_FLAGS() NL_SETUP_PREFIX_PATHS() RYZOM_SETUP_PREFIX_PATHS() +#----------------------------------------------------------------------------- +# Default values for URL's +SET(RYZOM_CLIENT_CREATE_ACCOUNT_URL "https://open.ryzom.dev/ams/" CACHE STRING "Ryzom Client Create Account URL") +SET(RYZOM_CLIENT_EDIT_ACCOUNT_URL "https://open.ryzom.dev/ams/" CACHE STRING "Ryzom Client Edit Account URL") +SET(RYZOM_CLIENT_FORGET_PASSWORD_URL "https://open.ryzom.dev/ams/" CACHE STRING "Ryzom Client Forget Password URL") +SET(RYZOM_CLIENT_PATCH_URL "https://cdn.ryzom.dev/open/patch/" CACHE STRING "Ryzom Client Patch URL") + +SET(RYZOM_WEBIG_MAIN_URL "https://open.ryzom.dev/" CACHE STRING "Ryzom Client WebIG Main URL") +SET(RYZOM_WEBIG_TRUSTED_DOMAIN "open.ryzom.dev" CACHE STRING "Ryzom Client WebIG Trusted Domain") + +#----------------------------------------------------------------------------- +# urls when compiling ryzom live client +IF(WITH_RYZOM_LIVE) + MESSAGE("Using RYZOM_LIVE urls") + SET(RYZOM_CLIENT_CREATE_ACCOUNT_URL "https://account.ryzom.com/signup/from_client.php") + SET(RYZOM_CLIENT_EDIT_ACCOUNT_URL "https://account.ryzom.com/payment_profile/index.php") + SET(RYZOM_CLIENT_FORGET_PASSWORD_URL "https://account.ryzom.com/payment_profile/lost_secure_password.php") + SET(RYZOM_CLIENT_PATCH_URL "http://dl.ryzom.com/patch_live") + + SET(RYZOM_WEBIG_MAIN_URL "https://app.ryzom.com/") + SET(RYZOM_WEBIG_TRUSTED_DOMAIN "app.ryzom.com") +ENDIF() + #----------------------------------------------------------------------------- #Platform specifics @@ -216,6 +239,8 @@ IF(WITH_NEL) IF(WITH_GUI) FIND_PACKAGE(Luabind REQUIRED) + ENDIF() + FIND_PACKAGE(CURL REQUIRED) IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL) @@ -265,7 +290,6 @@ IF(WITH_NEL) ENDIF() ENDIF() ENDIF() - ENDIF() INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include) ADD_SUBDIRECTORY(nel) diff --git a/code/CMakeModules/ConfigureChecks.cmake b/code/CMakeModules/ConfigureChecks.cmake index 1eade142c..9de2e8214 100644 --- a/code/CMakeModules/ConfigureChecks.cmake +++ b/code/CMakeModules/ConfigureChecks.cmake @@ -37,15 +37,25 @@ MACRO(NL_CONFIGURE_CHECKS) SET(RYZOM_VERSION_PATCH ${NL_VERSION_PATCH}) ENDIF() - SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}.${REVISION}") + IF(DESCRIBE) + SET(NL_VERSION "${DESCRIBE}") + ELSE() + SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}.${REVISION}") + ENDIF() SET(NL_VERSION_RC "${NL_VERSION_MAJOR},${NL_VERSION_MINOR},${NL_VERSION_PATCH},${REVISION}") + SET(NL_PRODUCT_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}") SET(RYZOM_VERSION_SHORT "${RYZOM_VERSION_MAJOR}.${RYZOM_VERSION_MINOR}.${RYZOM_VERSION_PATCH}") - SET(RYZOM_VERSION "${RYZOM_VERSION_SHORT}.${REVISION}") + IF(DESCRIBE) + SET(RYZOM_VERSION "${DESCRIBE}") + ELSE() + SET(RYZOM_VERSION "${RYZOM_VERSION_SHORT}.${REVISION}") + ENDIF() SET(RYZOM_VERSION_RC "${RYZOM_VERSION_MAJOR},${RYZOM_VERSION_MINOR},${RYZOM_VERSION_PATCH},${REVISION}") + SET(RYZOM_PRODUCT_VERSION "${RYZOM_VERSION_MAJOR}.${RYZOM_VERSION_MINOR}.${RYZOM_VERSION_PATCH}") NOW(BUILD_DATE) - SET(COPYRIGHT "${YEAR} ${AUTHOR}") + SET(COPYRIGHT "Copyright (C) ${YEAR} ${AUTHOR}") IF(NOT RYZOM_CLIENT_ICON) SET(RYZOM_CLIENT_ICON "ryzom_client") diff --git a/code/CMakeModules/Find3dsMaxSDK.cmake b/code/CMakeModules/Find3dsMaxSDK.cmake index cf49a90d3..cb00df78e 100644 --- a/code/CMakeModules/Find3dsMaxSDK.cmake +++ b/code/CMakeModules/Find3dsMaxSDK.cmake @@ -11,18 +11,56 @@ if(MAXSDK_INCLUDE_DIR) SET(MAXSDK_FIND_QUIETLY TRUE) endif() +set(_pf_x86 "PROGRAMFILES(x86)") + FIND_PATH(MAXSDK_DIR "include/maxversion.h" HINTS "$ENV{MAXSDK_DIR}" PATHS + "$ENV{ADSK_3DSMAX_SDK_2021}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2020}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2019}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2018}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2017}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2016}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2015}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2014}/maxsdk" + "$ENV{ADSK_3DSMAX_SDK_2013}/maxsdk" "$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk" "$ENV{3DSMAX_2011_SDK_PATH}/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2021 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2020 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2019 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2018 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2017 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2016 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2015 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2014 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2013 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2012 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2011 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2010 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2009 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 2008 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3ds Max 9 SDK/maxsdk" + "$ENV{${_pf_x86}}/Autodesk/3dsMax8/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2021 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2020 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2019 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2018 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2017 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2016 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2015 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2014 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2013 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2012 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2011 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk" + "$ENV{PROGRAMFILES}/Autodesk/3dsMax8/maxsdk" ) FIND_PATH(MAXSDK_INCLUDE_DIR diff --git a/code/CMakeModules/FindFMOD.cmake b/code/CMakeModules/FindFMOD.cmake index b28f77b1e..3bdd09e8f 100644 --- a/code/CMakeModules/FindFMOD.cmake +++ b/code/CMakeModules/FindFMOD.cmake @@ -1,57 +1,9 @@ -# - Locate FMOD library -# This module defines -# FMOD_LIBRARY, the library to link against -# FMOD_FOUND, if false, do not try to link to FMOD -# FMOD_INCLUDE_DIR, where to find headers. - -IF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) - # in cache already - SET(FMOD_FIND_QUIETLY TRUE) -ENDIF() - - -FIND_PATH(FMOD_INCLUDE_DIR - fmod.h - PATHS - $ENV{FMOD_DIR}/include - /usr/local/include - /usr/include - /sw/include - /opt/local/include - /opt/csw/include - /opt/include - PATH_SUFFIXES fmod fmod3 -) +INCLUDE(FindHelpers) IF(TARGET_X64) - SET(FMOD_LIBRARY_NAMES fmod64 fmod) + SET(FMOD_BASE fmod64) ELSE() - SET(FMOD_LIBRARY_NAMES fmodvc fmod) + SET(FMOD_BASE fmodvc) ENDIF() -FIND_LIBRARY(FMOD_LIBRARY - NAMES - ${FMOD_LIBRARY_NAMES} - PATHS - $ENV{FMOD_DIR}/lib - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -IF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR) - SET(FMOD_FOUND "YES") - IF(NOT FMOD_FIND_QUIETLY) - MESSAGE(STATUS "Found FMOD: ${FMOD_LIBRARY}") - ENDIF() -ELSE() - IF(NOT FMOD_FIND_QUIETLY) - MESSAGE(STATUS "Warning: Unable to find FMOD!") - ENDIF() -ENDIF() +FIND_PACKAGE_HELPER(FMOD fmod.h RELEASE ${FMOD_BASE} DEBUG ${FMOD_BASE}d SUFFIXES fmod3) diff --git a/code/CMakeModules/FindGLIB2.cmake b/code/CMakeModules/FindGLIB2.cmake new file mode 100644 index 000000000..942b04530 --- /dev/null +++ b/code/CMakeModules/FindGLIB2.cmake @@ -0,0 +1,217 @@ +# - Try to find GLib2 +# Once done this will define +# +# GLIB2_FOUND - system has GLib2 +# GLIB2_INCLUDE_DIRS - the GLib2 include directory +# GLIB2_LIBRARIES - Link these to use GLib2 +# +# HAVE_GLIB_GREGEX_H glib has gregex.h header and +# supports g_regex_match_simple +# +# Copyright (c) 2006 Andreas Schneider +# Copyright (c) 2006 Philippe Bernery +# Copyright (c) 2007 Daniel Gollub +# Copyright (c) 2007 Alban Browaeys +# Copyright (c) 2008 Michael Bell +# Copyright (c) 2008 Bjoern Ricks +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) + # in cache already + SET(GLIB2_FOUND TRUE) +ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) + + INCLUDE(FindPkgConfig) + + ## Glib + IF ( GLIB2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) + ELSE ( GLIB2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) + ENDIF ( GLIB2_FIND_REQUIRED ) + + IF ( GLIB2_MIN_VERSION ) + PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) + ELSE ( GLIB2_MIN_VERSION ) + PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) + ENDIF ( GLIB2_MIN_VERSION ) + IF ( PKG_CONFIG_FOUND ) + IF ( GLIB2_FOUND ) + SET ( GLIB2_CORE_FOUND TRUE ) + ELSE ( GLIB2_FOUND ) + SET ( GLIB2_CORE_FOUND FALSE ) + ENDIF ( GLIB2_FOUND ) + ENDIF ( PKG_CONFIG_FOUND ) + + # Look for glib2 include dir and libraries w/o pkgconfig + IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) + FIND_PATH( + _glibconfig_include_DIR + NAMES + glibconfig.h + PATHS + /opt/gnome/lib64 + /opt/gnome/lib + /opt/lib/ + /opt/local/lib + /sw/lib/ + /usr/lib64 + /usr/lib + /usr/local/include + ${CMAKE_LIBRARY_PATH} + PATH_SUFFIXES + glib-2.0/include + ) + + FIND_PATH( + _glib2_include_DIR + NAMES + glib.h + PATHS + /opt/gnome/include + /opt/local/include + /sw/include + /usr/include + /usr/local/include + PATH_SUFFIXES + glib-2.0 + ) + + #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") + + FIND_LIBRARY( + _glib2_link_DIR + NAMES + glib-2.0 + glib + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + ) + IF ( _glib2_include_DIR AND _glib2_link_DIR ) + SET ( _glib2_FOUND TRUE ) + ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) + + + IF ( _glib2_FOUND ) + SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) + SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) + SET ( GLIB2_CORE_FOUND TRUE ) + ELSE ( _glib2_FOUND ) + SET ( GLIB2_CORE_FOUND FALSE ) + ENDIF ( _glib2_FOUND ) + + # Handle dependencies + # libintl + IF ( NOT LIBINTL_FOUND ) + FIND_PATH(LIBINTL_INCLUDE_DIR + NAMES + libintl.h + PATHS + /opt/gnome/include + /opt/local/include + /sw/include + /usr/include + /usr/local/include + ) + + FIND_LIBRARY(LIBINTL_LIBRARY + NAMES + intl + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/local/lib + /usr/lib + ) + + IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) + SET (LIBINTL_FOUND TRUE) + ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) + ENDIF ( NOT LIBINTL_FOUND ) + + # libiconv + IF ( NOT LIBICONV_FOUND ) + FIND_PATH(LIBICONV_INCLUDE_DIR + NAMES + iconv.h + PATHS + /opt/gnome/include + /opt/local/include + /opt/local/include + /sw/include + /sw/include + /usr/local/include + /usr/include + PATH_SUFFIXES + glib-2.0 + ) + + FIND_LIBRARY(LIBICONV_LIBRARY + NAMES + iconv + PATHS + /opt/gnome/lib + /opt/local/lib + /sw/lib + /usr/lib + /usr/local/lib + ) + + IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + SET (LIBICONV_FOUND TRUE) + ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) + ENDIF ( NOT LIBICONV_FOUND ) + + IF (LIBINTL_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) + ENDIF (LIBINTL_FOUND) + + IF (LIBICONV_FOUND) + SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) + SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) + ENDIF (LIBICONV_FOUND) + + ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) + ## + + IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) + SET (GLIB2_FOUND TRUE) + ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) + + IF (GLIB2_FOUND) + IF (NOT GLIB2_FIND_QUIETLY) + MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") + ENDIF (NOT GLIB2_FIND_QUIETLY) + ELSE (GLIB2_FOUND) + IF (GLIB2_FIND_REQUIRED) + MESSAGE (SEND_ERROR "Could not find GLib2") + ENDIF (GLIB2_FIND_REQUIRED) + ENDIF (GLIB2_FOUND) + + # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view + MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) + MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) + MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) + +ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) + +IF ( GLIB2_FOUND ) + # Check if system has a newer version of glib + # which supports g_regex_match_simple + INCLUDE( CheckIncludeFiles ) + SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) + CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) + # Reset CMAKE_REQUIRED_INCLUDES + SET( CMAKE_REQUIRED_INCLUDES "" ) +ENDIF( GLIB2_FOUND ) diff --git a/code/CMakeModules/FindGOBJECT2.cmake b/code/CMakeModules/FindGOBJECT2.cmake new file mode 100644 index 000000000..d0d4cda0d --- /dev/null +++ b/code/CMakeModules/FindGOBJECT2.cmake @@ -0,0 +1,51 @@ +# - Try to find GObject2 +# Find GObject2 headers, libraries and the answer to all questions. +# +# GOBJECT2_FOUND True if GOBJECT2 got found +# GOBJECT2_INCLUDE_DIRS Location of GOBJECT2 headers +# GOBJECT2_LIBRARIES List of libraries to use GOBJECT2 +# +# Copyright (c) 2008 Bjoern Ricks +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +INCLUDE( FindPkgConfig ) + +IF ( GOBJECT2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) +ELSE( GOBJECT2_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) +ENDIF ( GOBJECT2_FIND_REQUIRED ) + +IF ( GOBJECT2_MIN_VERSION ) + PKG_SEARCH_MODULE( GOBJECT2 ${_pkgconfig_REQUIRED} gobject-2.0>=${GOBJECT2_MIN_VERSION} ) +ELSE ( GOBJECT2_MIN_VERSION ) + PKG_SEARCH_MODULE( GOBJECT2 ${_pkgconfig_REQUIRED} gobject-2.0 ) +ENDIF ( GOBJECT2_MIN_VERSION ) + + +IF( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND ) + FIND_PATH( GOBJECT2_INCLUDE_DIRS gobject/gobject.h PATH_SUFFIXES glib-2.0) + FIND_LIBRARY( GOBJECT2_LIBRARIES gobject-2.0 ) + + # Report results + IF ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS ) + SET( GOBJECT2_FOUND 1 ) + IF ( NOT GOBJECT2_FIND_QUIETLY ) + MESSAGE( STATUS "Found GOBJECT2: ${GOBJECT2_LIBRARIES}" ) + ENDIF ( NOT GOBJECT2_FIND_QUIETLY ) + ELSE ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS ) + IF ( GOBJECT2_FIND_REQUIRED ) + MESSAGE( SEND_ERROR "Could NOT find GOBJECT2" ) + ELSE ( GOBJECT2_FIND_REQUIRED ) + IF ( NOT GOBJECT2_FIND_QUIETLY ) + MESSAGE( STATUS "Could NOT find GOBJECT2" ) + ENDIF ( NOT GOBJECT2_FIND_QUIETLY ) + ENDIF ( GOBJECT2_FIND_REQUIRED ) + ENDIF ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS ) +ENDIF( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND ) + +MARK_AS_ADVANCED( GOBJECT2_LIBRARIES GOBJECT2_INCLUDE_DIRS ) diff --git a/code/CMakeModules/FindLIBGSF.cmake b/code/CMakeModules/FindLIBGSF.cmake new file mode 100644 index 000000000..8d749a87d --- /dev/null +++ b/code/CMakeModules/FindLIBGSF.cmake @@ -0,0 +1,57 @@ +# - Try to find libGSF +# +# Once done this will define +# +# LIBGSF_FOUND - System has LibGSF +# LIBGSF_INCLUDE_DIR - The LibGSF include directory +# LIBGSF_LIBRARIES - The libraries needed to use LibGSF +# LIBGSF_DEFINITIONS - Compiler switches required for using LibGSF +# LIBGSF_GSF_EXECUTABLE - The archive utility +# LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE - The office files thumbnailer for the GNOME desktop +# LIBGSF_GSFVBADUMP_EXECUTABLE - The utility to extract Visual Basic for Applications macros + +# Copyright (c) 2009, Pau Garcia i Quiles +# Based off FindLibXml2.cmake from CMake 2.6.4 by Alexander Neundorf +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +IF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES) + # in cache already + SET(LIBGSF_FIND_QUIETLY TRUE) +ENDIF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES) + +IF (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + FIND_PACKAGE(PkgConfig) + PKG_CHECK_MODULES(PC_LIBGSF libgsf-1) + SET(LIBGSF_DEFINITIONS ${PC_LIBGSF_CFLAGS_OTHER}) +ENDIF (NOT WIN32) + +FIND_PATH(LIBGSF_INCLUDE_DIR gsf/gsf.h + HINTS + ${PC_LIBGSF_INCLUDEDIR} + ${PC_LIBGSF_INCLUDE_DIRS} + PATH_SUFFIXES libgsf-1 + ) + +FIND_LIBRARY(LIBGSF_LIBRARIES NAMES gsf-1 libgsf-1 + HINTS + ${PC_LIBGSF_LIBDIR} + ${PC_LIBGSF_LIBRARY_DIRS} + ) + +FIND_PROGRAM(LIBGSF_GSF_EXECUTABLE gsf) +FIND_PROGRAM(LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE gsf-office-thumbnailer) +FIND_PROGRAM(LIBGSF_GSFVBADUMP_EXECUTABLE gsf-vba-dump) + +INCLUDE(FindPackageHandleStandardArgs) + +# handle the QUIETLY and REQUIRED arguments and set LIBGSF_FOUND to TRUE if +# all listed variables are TRUE +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGSF DEFAULT_MSG LIBGSF_LIBRARIES LIBGSF_INCLUDE_DIR) + +MARK_AS_ADVANCED(LIBGSF_INCLUDE_DIR LIBGSF_LIBRARIES LIBGSF_GSF_EXECUTABLE LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE LIBGSF_GSFVBADUMP_EXECUTABLE ) + diff --git a/code/CMakeModules/FindLuabind.cmake b/code/CMakeModules/FindLuabind.cmake index 5511379a3..dae1dbd99 100644 --- a/code/CMakeModules/FindLuabind.cmake +++ b/code/CMakeModules/FindLuabind.cmake @@ -3,6 +3,7 @@ # LUABIND_LIBRARIES, the libraries to link against # LUABIND_FOUND, if false, do not try to link to LUABIND # LUABIND_INCLUDE_DIR, where to find headers. +INCLUDE(FindHelpers) MACRO(FIND_CORRECT_LUA_VERSION) # Check Lua version linked to Luabind under Linux @@ -85,18 +86,6 @@ IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) SET(Luabind_FIND_QUIETLY TRUE) ENDIF() -FIND_PATH(LUABIND_INCLUDE_DIR - luabind/luabind.hpp - PATHS - $ENV{LUABIND_DIR}/include - /usr/local/include - /usr/include - /sw/include - /opt/local/include - /opt/csw/include - /opt/include -) - SET(LIBRARY_NAME_RELEASE) SET(LIBRARY_NAME_DEBUG) @@ -149,35 +138,7 @@ ENDIF() LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind) LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd) -FIND_LIBRARY(LUABIND_LIBRARY_RELEASE - NAMES ${LIBRARY_NAME_RELEASE} - PATHS - $ENV{LUABIND_DIR}/lib - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -FIND_LIBRARY(LUABIND_LIBRARY_DEBUG - NAMES ${LIBRARY_NAME_DEBUG} - PATHS - $ENV{LUABIND_DIR}/lib - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) +FIND_PACKAGE_HELPER(Luabind luabind/luabind.hpp RELEASE ${LIBRARY_NAME_RELEASE} DEBUG ${LIBRARY_NAME_DEBUG}) FIND_PACKAGE(Boost REQUIRED) diff --git a/code/CMakeModules/FindMSVC.cmake b/code/CMakeModules/FindMSVC.cmake index 5dbc4f6a8..2a08a08bb 100644 --- a/code/CMakeModules/FindMSVC.cmake +++ b/code/CMakeModules/FindMSVC.cmake @@ -1,89 +1,55 @@ # - Find MS Visual C++ # +# VC_DIR - where to find Visual C++ # VC_INCLUDE_DIR - where to find headers # VC_INCLUDE_DIRS - where to find headers # VC_LIBRARY_DIR - where to find libraries -# VC_FOUND - True if MSVC found. - -MACRO(ADD_TRAILING_SLASH _FILENAME_VAR) - # put content in a new variable - SET(_FILENAME ${${_FILENAME_VAR}}) - # get length of the string - STRING(LENGTH ${_FILENAME} _LEN) - # convert length to last pos - MATH(EXPR _POS "${_LEN}-1") - # get last character of the string - STRING(SUBSTRING ${_FILENAME} ${_POS} 1 _FILENAME_END) - # compare it with a slash - IF(NOT _FILENAME_END STREQUAL "/") - # not a slash, append it - SET(${_FILENAME_VAR} "${_FILENAME}/") - ELSE() - # already a slash - ENDIF() -ENDMACRO() - -MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION) - # Software/Wow6432Node/... - GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;${_VERSION}]" ABSOLUTE) - - IF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry") - SET(VC${_VERSION}_DIR) - GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE) - - IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") - # be sure it's finishing by a / - ADD_TRAILING_SLASH(VC${_VERSION}_DIR) - - SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/") - ENDIF() - ENDIF() +# VC_FOUND - True if MSVC found + +IF(CMAKE_CXX_COMPILER) + SET(_COMPILER ${CMAKE_CXX_COMPILER}) + SET(_VERSION ${CMAKE_CXX_COMPILER_VERSION}) +ELSEIF(CMAKE_C_COMPILER) + SET(_COMPILER ${CMAKE_C_COMPILER}) + SET(_VERSION ${CMAKE_C_COMPILER_VERSION}) +ELSE() + MESSAGE(FATAL_ERROR "No way to determine Visual C++ location") +ENDIF() - IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") - SET(VC${_VERSION}_FOUND ON) - DETECT_EXPRESS_VERSION(${_VERSION}) - IF(NOT MSVC_FIND_QUIETLY) - SET(_VERSION_STR ${_VERSION}) - IF(MSVC_EXPRESS) - SET(_VERSION_STR "${_VERSION_STR} Express") - ENDIF() - MESSAGE(STATUS "Found Visual C++ ${_VERSION_STR} in ${VC${_VERSION}_DIR}") - ENDIF() - ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") - SET(VC${_VERSION}_FOUND OFF) - SET(VC${_VERSION}_DIR "") +IF(MSVC_VERSION LESS 1910) + IF(MSVC_VERSION LESS 1500) + MESSAGE(FATAL_ERROR "Unsupported version of Visual C++ (minimum version is 2008)") + ELSEIF(MSVC_VERSION LESS 1600) + SET(MSVC_TOOLSET "90") + SET(_NAME "2008") + ELSEIF(MSVC_VERSION LESS 1700) + SET(MSVC_TOOLSET "100") + SET(_NAME "2010") + ELSEIF(MSVC_VERSION LESS 1800) + SET(MSVC_TOOLSET "110") + SET(_NAME "2012") + ELSEIF(MSVC_VERSION LESS 1900) + SET(MSVC_TOOLSET "120") + SET(_NAME "2013") + ELSE() + SET(MSVC_TOOLSET "140") + SET(_NAME "2015") ENDIF() -ENDMACRO() - -MACRO(DETECT_VC_VERSION _VERSION) - IF(NOT VC_FOUND) - SET(VC${_VERSION}_FOUND OFF) - DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION}) - IF(NOT VC${_VERSION}_FOUND) - DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) - ENDIF() + STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER}) - IF(VC${_VERSION}_FOUND) - SET(VC_FOUND ON) - SET(VC_DIR "${VC${_VERSION}_DIR}") - ENDIF() - ENDIF() -ENDMACRO() - -MACRO(DETECT_EXPRESS_VERSION _VERSION) - GET_FILENAME_COMPONENT(MSVC_EXPRESS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\${_VERSION}\\Setup\\VC;ProductDir]" ABSOLUTE) + MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION}) in ${VC_DIR}") +ELSE() + # Toolset = version of runtime DLLs + SET(MSVC_TOOLSET "140") - IF(MSVC_EXPRESS AND NOT MSVC_EXPRESS STREQUAL "/registry") - SET(MSVC_EXPRESS ON) + IF(MSVC_VERSION LESS 1920) + SET(_NAME "2017") + ELSE() + SET(_NAME "2019") ENDIF() -ENDMACRO() - -IF(MSVC_VERSION GREATER 1909) - DETECT_VC_VERSION("15.0") - SET(MSVC_TOOLSET "140") - SET(VC_DIR "${VC_DIR}Tools/MSVC") + STRING(REGEX REPLACE "/MSVC/.+" "/MSVC" VC_DIR ${_COMPILER}) FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*") @@ -92,48 +58,15 @@ IF(MSVC_VERSION GREATER 1909) LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS) ENDIF() - IF(NOT MSVC_TOOLCHAIN_VERSIONS) - MESSAGE(FATAL_ERROR "No MSVC version found in default search path ${VC_DIR}") - ENDIF() - - LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION) - - SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}") - SET(VC_INCLUDE_DIR "${VC_DIR}/include") -ELSEIF(MSVC14) - DETECT_VC_VERSION("14.0") - SET(MSVC_TOOLSET "140") -ELSEIF(MSVC12) - DETECT_VC_VERSION("12.0") - SET(MSVC_TOOLSET "120") -ELSEIF(MSVC11) - DETECT_VC_VERSION("11.0") - SET(MSVC_TOOLSET "110") -ELSEIF(MSVC10) - DETECT_VC_VERSION("10.0") - SET(MSVC_TOOLSET "100") -ELSEIF(MSVC90) - DETECT_VC_VERSION("9.0") - SET(MSVC_TOOLSET "90") -ELSEIF(MSVC80) - DETECT_VC_VERSION("8.0") - SET(MSVC_TOOLSET "80") -ENDIF() + IF(MSVC_TOOLCHAIN_VERSIONS) + LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION) -# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable -IF(NOT VC_DIR) - SET(VC_DIR $ENV{VC_DIR}) - # Fix path - FILE(TO_CMAKE_PATH ${VC_DIR} VC_DIR) -ENDIF() + SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}") -IF(NOT VC_DIR) - IF(CMAKE_CXX_COMPILER) - SET(_COMPILER ${CMAKE_CXX_COMPILER}) + MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION} with toolchain ${MSVC_TOOLCHAIN_VERSION}) in ${VC_DIR}") ELSE() - SET(_COMPILER ${CMAKE_C_COMPILER}) + MESSAGE(FATAL_ERROR "Unable to find Visual C++ in ${VC_DIR}") ENDIF() - STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER}) ENDIF() IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}") @@ -147,14 +80,14 @@ SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist") IF(NOT EXISTS "${MSVC_REDIST_DIR}") SET(MSVC_REDIST_DIR "${VC_DIR}/redist") - + IF(NOT EXISTS "${MSVC_REDIST_DIR}") SET(MSVC_REDIST_DIR) ENDIF() ENDIF() IF(MSVC_REDIST_DIR) - IF(MSVC1411 OR MSVC1410) + IF(MSVC_VERSION GREATER 1909) # If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist # original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}") @@ -167,7 +100,7 @@ IF(MSVC_REDIST_DIR) # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist SET(MSVC11_REDIST_DIR "${MSVC_REDIST_DIR}") ELSEIF(MSVC10) - # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist + # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist SET(MSVC10_REDIST_DIR "${MSVC_REDIST_DIR}") ELSEIF(MSVC90) SET(MSVC90_REDIST_DIR "${MSVC_REDIST_DIR}") @@ -176,7 +109,11 @@ IF(MSVC_REDIST_DIR) ENDIF() ENDIF() -MESSAGE(STATUS "Using headers from ${VC_INCLUDE_DIR}") +IF(VC_INCLUDE_DIR) + MESSAGE(STATUS "Using VC++ headers from ${VC_INCLUDE_DIR}") +ELSE() + MESSAGE(FATAL_ERROR "Unable to find VC++ headers") +ENDIF() SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR}) diff --git a/code/CMakeModules/FindMySQL.cmake b/code/CMakeModules/FindMySQL.cmake index 8a92cb0c4..631a96224 100644 --- a/code/CMakeModules/FindMySQL.cmake +++ b/code/CMakeModules/FindMySQL.cmake @@ -16,10 +16,12 @@ IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) ELSE() FIND_PATH(MYSQL_INCLUDE_DIR mysql.h - PATH_SUFFIXES mysql + PATH_SUFFIXES mysql mariadb PATHS /usr/include/mysql + /usr/include/mariadb /usr/local/include/mysql + /usr/local/include/mariadb /opt/local/include/mysql5/mysql /opt/local/include/mysql55/mysql /opt/local/include/mysql51/mysql @@ -27,28 +29,29 @@ ELSE() $ENV{SystemDrive}/MySQL/*/include) IF(WIN32 AND MSVC) - FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient + FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient libmariadb mariadbclient PATHS $ENV{ProgramFiles}/MySQL/*/lib/opt $ENV{SystemDrive}/MySQL/*/lib/opt) - - FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd + FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd libmariadb mariadbclient PATHS $ENV{ProgramFiles}/MySQL/*/lib/opt $ENV{SystemDrive}/MySQL/*/lib/opt) ELSE() - FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient + FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient mariadbclient PATHS /usr/lib /usr/local/lib + /usr/lib/mariadb /usr/lib/mysql /usr/local/lib/mysql + /usr/local/lib/mariadb /opt/local/lib/mysql5/mysql /opt/local/lib/mysql55/mysql /opt/local/lib/mysql51/mysql ) - FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd + FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd mariadbclientd PATHS /usr/lib /usr/local/lib @@ -80,6 +83,10 @@ ELSE() IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) SET(MYSQL_FOUND TRUE) MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}") + IF (MYSQL_LIBRARIES MATCHES "libmariadb" OR MYSQL_LIBRARIES MATCHES "mariadbclient") + SET(MARIADB_FOUND TRUE) + MESSAGE(STATUS "Found MariaDB.") + ENDIF() ELSE() SET(MYSQL_FOUND FALSE) MESSAGE(STATUS "MySQL not found.") diff --git a/code/CMakeModules/FindNeL.cmake b/code/CMakeModules/FindNeL.cmake index e75163cce..96dd90b83 100644 --- a/code/CMakeModules/FindNeL.cmake +++ b/code/CMakeModules/FindNeL.cmake @@ -13,7 +13,6 @@ # NELXXX_FOUND # NELXXX_LIBRARIES - INCLUDE(FindHelpers) # Init all variables we'll set @@ -209,6 +208,20 @@ IF(NELMISC_FOUND) LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES}) ENDIF() + IF(CMAKE_DL_LIBS) + LIST(APPEND NELMISC_LIBRARIES ${CMAKE_DL_LIBS}) + ENDIF() + + FIND_PACKAGE(Threads) + + IF(Threads_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + ENDIF() + + IF(UNIX AND NOT APPLE) + LIST(APPEND NELMISC_LIBRARIES rt) + ENDIF() + LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc) LIST(APPEND NEL_MODULES_FOUND misc) @@ -262,11 +275,17 @@ FOREACH(COMPONENT ${NeL_FIND_COMPONENTS}) FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE} RELEASE nel${COMPONENT}_r nel${COMPONENT} DEBUG nel${COMPONENT}_d + DIR ${NEL_DIR} QUIET) IF(${_UPNAME}_FOUND) LIST(APPEND NEL_MODULES_FOUND ${COMPONENT}) + # all NeL libraries depend on nelmisc in static + IF(NEL_STATIC) + LIST(APPEND ${_UPNAME}_LIBRARIES ${NELMISC_LIBRARIES}) + ENDIF() + IF(COMPONENT STREQUAL "3d") IF(NEL_STATIC) # 3rd party dependencies @@ -301,7 +320,9 @@ FOREACH(COMPONENT ${NeL_FIND_COMPONENTS}) ELSEIF(COMPONENT STREQUAL "gui") FIND_PACKAGE(Luabind REQUIRED) - LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES}) + IF(LUABIND_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES}) + ENDIF() FIND_LIBCURL() @@ -323,7 +344,6 @@ FOREACH(COMPONENT ${NeL_FIND_COMPONENTS}) LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) - LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS}) ELSEIF(COMPONENT STREQUAL "sound") FIND_PACKAGE(Ogg REQUIRED) diff --git a/code/CMakeModules/FindOgg.cmake b/code/CMakeModules/FindOgg.cmake index c1f4492e1..aa2f9164c 100644 --- a/code/CMakeModules/FindOgg.cmake +++ b/code/CMakeModules/FindOgg.cmake @@ -1,49 +1,3 @@ -# - Locate Ogg library -# This module defines -# OGG_LIBRARY, the library to link against -# OGG_FOUND, if false, do not try to link to OGG -# OGG_INCLUDE_DIR, where to find headers. +INCLUDE(FindHelpers) -IF(OGG_LIBRARY AND OGG_INCLUDE_DIR) - # in cache already - SET(OGG_FIND_QUIETLY TRUE) -ENDIF() - - -FIND_PATH(OGG_INCLUDE_DIR - ogg/ogg.h - PATHS - $ENV{OGG_DIR}/include - /usr/local/include - /usr/include - /sw/include - /opt/local/include - /opt/csw/include - /opt/include -) - -FIND_LIBRARY(OGG_LIBRARY - NAMES ogg libogg - PATHS - $ENV{OGG_DIR}/lib - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -IF(OGG_LIBRARY AND OGG_INCLUDE_DIR) - SET(OGG_FOUND "YES") - IF(NOT OGG_FIND_QUIETLY) - MESSAGE(STATUS "Found Ogg: ${OGG_LIBRARY}") - ENDIF() -ELSE() - IF(NOT OGG_FIND_QUIETLY) - MESSAGE(STATUS "Warning: Unable to find Ogg!") - ENDIF() -ENDIF() +FIND_PACKAGE_HELPER(Ogg ogg/ogg.h) diff --git a/code/CMakeModules/FindSTLport.cmake b/code/CMakeModules/FindSTLport.cmake index 68e542ea5..3b1cc1800 100644 --- a/code/CMakeModules/FindSTLport.cmake +++ b/code/CMakeModules/FindSTLport.cmake @@ -1,91 +1,5 @@ -# Look for a directory containing STLport. -# -# The following values are defined -# STLPORT_INCLUDE_DIR - where to find vector, etc. -# STLPORT_LIBRARIES - link against these to use STLport -# STLPORT_FOUND - True if the STLport is available. +INCLUDE(FindHelpers) -# also defined, but not for general use are -IF(STLPORT_LIBRARIES AND STLPORT_INCLUDE_DIR) - # in cache already - SET(STLPORT_FIND_QUIETLY TRUE) -ENDIF() - -FIND_PATH(STLPORT_INCLUDE_DIR - iostream - PATHS - /usr/local/include - /usr/include - /sw/include - /opt/local/include - /opt/csw/include - /opt/include - PATH_SUFFIXES stlport -) - -FIND_LIBRARY(STLPORT_LIBRARY_DEBUG - NAMES - stlport_cygwin_debug - stlport_cygwin_stldebug - stlport_gcc_debug - stlport_gcc_stldebug - stlportstld_x - stlportstld_x.5.2 - stlportd - stlportd_statix - stlportd_static - PATHS - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -FIND_LIBRARY(STLPORT_LIBRARY_RELEASE - NAMES - stlport_cygwin - stlport_gcc - stlport - stlport_x - stlport_x.5.2 - stlport_statix - stlport_static - PATHS - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -IF(STLPORT_INCLUDE_DIR) - IF(STLPORT_LIBRARY_RELEASE) - SET(STLPORT_FOUND TRUE) - - SET(STLPORT_LIBRARIES ${STLPORT_LIBRARY_RELEASE}) - IF(STLPORT_LIBRARY_DEBUG) - SET(STLPORT_LIBRARIES optimized ${STLPORT_LIBRARIES} debug ${STLPORT_LIBRARY_DEBUG}) - ENDIF() - ENDIF() -ENDIF() - -IF(STLPORT_FOUND) - IF(NOT STLPORT_FIND_QUIETLY) - MESSAGE(STATUS "Found STLport: ${STLPORT_LIBRARIES}") - ENDIF() -ELSE() - IF(NOT STLPORT_FIND_QUIETLY) - MESSAGE(STATUS "Warning: Unable to find STLport!") - ENDIF() -ENDIF() - -MARK_AS_ADVANCED(STLPORT_LIBRARY_RELEASE STLPORT_LIBRARY_DEBUG) +FIND_PACKAGE_HELPER(STLport iostream + RELEASE stlport_cygwin stlport_gcc stlport_x stlport_x.5.2 stlport_statix stlport_static + DEBUG stlport_cygwin_debug stlport_cygwin_stldebug stlport_gcc_debug stlport_gcc_stldebug stlportstld_x stlportstld_x.5.2 stlportd_statix stlportd_static) diff --git a/code/CMakeModules/FindSquish.cmake b/code/CMakeModules/FindSquish.cmake index 4242f4055..9d0928f87 100644 --- a/code/CMakeModules/FindSquish.cmake +++ b/code/CMakeModules/FindSquish.cmake @@ -1,69 +1,6 @@ -# -# Find the LibSquish includes and library -# -# This module defines -# SQUISH_INCLUDE_DIR, where to find squish.h -# SQUISH_LIBRARIES, where to find the Squish libraries. -# SQUISH_FOUND, If false, do not try to use Squish. +INCLUDE(FindHelpers) -# also defined, but not for general use are -IF(SQUISH_LIBRARIES AND SQUISH_INCLUDE_DIR) - # in cache already - SET(SQUISH_FIND_QUIETLY TRUE) -ENDIF() - -FIND_PATH(SQUISH_INCLUDE_DIR - squish.h - PATHS - /usr/local/include - /usr/include - /sw/include - /opt/local/include - /opt/csw/include - /opt/include - PATH_SUFFIXES cppunit -) - -FIND_LIBRARY(SQUISH_LIBRARY_RELEASE - squish - PATHS - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -FIND_LIBRARY(SQUISH_LIBRARY_DEBUG - squishd - PATHS - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -IF(SQUISH_INCLUDE_DIR) - IF(SQUISH_LIBRARY_RELEASE) - SET(SQUISH_FOUND "YES") - SET(SQUISH_LIBRARIES "optimized;${SQUISH_LIBRARY_RELEASE}") - IF(SQUISH_LIBRARY_DEBUG) - SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_DEBUG}") - ELSE() - SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_RELEASE}") - MESSAGE("Debug Squish NOT found, using the release version!") - ENDIF() - ENDIF() -ENDIF() +FIND_PACKAGE_HELPER(Squish squish.h) IF(SQUISH_FOUND) IF(NOT SQUISH_FIND_QUIETLY) @@ -74,10 +11,4 @@ IF(SQUISH_FOUND) SET(SQUISH_COMPRESS_HAS_METRIC ON) SET(SQUISH_DEFINITIONS -DSQUISH_COMPRESS_HAS_METRIC) ENDIF() -ELSE() - IF(NOT SQUISH_FIND_QUIETLY) - MESSAGE(STATUS "Warning: Unable to find Squish!") - ENDIF() ENDIF() - -MARK_AS_ADVANCED(SQUISH_LIBRARY_RELEASE SQUISH_LIBRARY_DEBUG) diff --git a/code/CMakeModules/FindVorbis.cmake b/code/CMakeModules/FindVorbis.cmake index 234d2d31a..b0a4ec2a6 100644 --- a/code/CMakeModules/FindVorbis.cmake +++ b/code/CMakeModules/FindVorbis.cmake @@ -1,65 +1,8 @@ -# - Locate Vorbis library -# This module defines -# VORBIS_LIBRARY, the library to link against -# VORBIS_FOUND, if false, do not try to link to VORBIS -# VORBIS_INCLUDE_DIR, where to find headers. +INCLUDE(FindHelpers) -IF(VORBIS_LIBRARY AND VORBIS_INCLUDE_DIR) - # in cache already - SET(VORBIS_FIND_QUIETLY TRUE) -ENDIF() - - -FIND_PATH(VORBIS_INCLUDE_DIR - vorbis/vorbisfile.h - PATHS - $ENV{VORBIS_DIR}/include - /usr/local/include - /usr/include - /sw/include - /opt/local/include - /opt/csw/include - /opt/include -) - -FIND_LIBRARY(VORBIS_LIBRARY - NAMES vorbis libvorbis - PATHS - $ENV{VORBIS_DIR}/lib - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) - -FIND_LIBRARY(VORBISFILE_LIBRARY - NAMES vorbisfile libvorbisfile - PATHS - $ENV{VORBIS_DIR}/lib - /usr/local/lib - /usr/lib - /usr/local/X11R6/lib - /usr/X11R6/lib - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 -) +FIND_PACKAGE_HELPER(Vorbis vorbisenc.h) +FIND_PACKAGE_HELPER(VorbisFile vorbisfile.h SUFFIXES vorbis) -IF(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR) - SET(VORBIS_FOUND "YES") - SET(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) - IF(NOT VORBIS_FIND_QUIETLY) - MESSAGE(STATUS "Found Vorbis: ${VORBIS_LIBRARY}") - ENDIF() -ELSE() - IF(NOT VORBIS_FIND_QUIETLY) - MESSAGE(STATUS "Warning: Unable to find Vorbis!") - ENDIF() +IF(VORBISFILE_FOUND) + SET(VORBIS_LIBRARIES ${VORBIS_LIBRARIES} ${VORBISFILE_LIBRARIES}) ENDIF() diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index 3d9c43bd9..1b02dffb3 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -20,6 +20,7 @@ MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION) IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry" AND EXISTS "${WINSDK${_VERSION}_DIR}/Include") SET(WINSDK${_VERSION}_FOUND ON) GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME) + IF(NOT WindowsSDK_FIND_QUIETLY) MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}") ENDIF() @@ -28,14 +29,14 @@ MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION) ENDIF() ENDMACRO() -MACRO(DETECT_WINKIT_VERSION _VERSION _SUFFIX) - GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot${_SUFFIX}]" ABSOLUTE) +MACRO(DETECT_WINKIT_VERSION_HELPER _VERSION _SUFFIX _PREFIX _ARCH) + GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\${_PREFIX}Microsoft\\Windows Kits\\Installed Roots;KitsRoot${_SUFFIX}]" ABSOLUTE) - IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") + IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry" AND EXISTS "${WINSDK${_VERSION}_DIR}/Include") SET(WINSDK${_VERSION}_FOUND ON) SET(WINSDK${_VERSION}_VERSION_FULL "${_VERSION}") IF(NOT WindowsSDK_FIND_QUIETLY) - MESSAGE(STATUS "Found Windows Kit ${_VERSION} in ${WINSDK${_VERSION}_DIR}") + MESSAGE(STATUS "Found Windows Kit ${_VERSION} in ${WINSDK${_VERSION}_DIR} (registry ${_ARCH} bits)") ENDIF() LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION}) ELSE() @@ -52,6 +53,14 @@ MACRO(DETECT_WINSDK_VERSION _VERSION) ENDIF() ENDMACRO() +MACRO(DETECT_WINKIT_VERSION _VERSION _SUFFIX) + DETECT_WINKIT_VERSION_HELPER("${_VERSION}" "${_SUFFIX}" "WOW6432Node\\\\" "32") + + IF(NOT WINSDK${_VERSION}_FOUND) + DETECT_WINKIT_VERSION_HELPER("${_VERSION}" "${_SUFFIX}" "" "64") + ENDIF() +ENDMACRO() + SET(WINSDK_DETECTED_VERSIONS) # Fixed versions for Windows Kits (VC++ from 2012) @@ -378,7 +387,11 @@ FIND_PATH(WINSDK_INCLUDE_DIR Windows.h NO_DEFAULT_PATH ) -MESSAGE(STATUS "Found Windows.h in ${WINSDK_INCLUDE_DIR}") +IF(WINSDK_INCLUDE_DIR) + MESSAGE(STATUS "Found Windows.h in ${WINSDK_INCLUDE_DIR}") +ELSE() + MESSAGE(FATAL_ERROR "Unable to find Windows.h") +ENDIF() # directory where WinRT headers are found FIND_PATH(WINSDK_WINRT_INCLUDE_DIR winstring.h diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index dba90c765..f18b662e1 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -72,6 +72,49 @@ IF(EXISTS "${ROOT_DIR}/.hg/") ENDIF() ENDIF() +IF(EXISTS "${ROOT_DIR}/.git/") + FIND_PACKAGE(Git) + + IF(GIT_FOUND) + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count + WORKING_DIRECTORY ${ROOT_DIR} + RESULT_VARIABLE git_exit_code + OUTPUT_VARIABLE REVISION) + IF(NOT ${git_exit_code} EQUAL 0) + MESSAGE(WARNING "git rev-list failed, unable to include version.") + ELSE() + STRING(STRIP ${REVISION} REVISION) + ENDIF() + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD + WORKING_DIRECTORY ${ROOT_DIR} + RESULT_VARIABLE git_exit_code + OUTPUT_VARIABLE CHANGESET) + IF(NOT ${git_exit_code} EQUAL 0) + MESSAGE(WARNING "git rev-parse failed, unable to include version.") + ELSE() + STRING(STRIP ${CHANGESET} CHANGESET) + ENDIF() + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${ROOT_DIR} + RESULT_VARIABLE git_exit_code + OUTPUT_VARIABLE BRANCH) + IF(NOT ${git_exit_code} EQUAL 0) + MESSAGE(WARNING "git rev-parse failed, unable to include git branch.") + ELSE() + STRING(STRIP ${BRANCH} BRANCH) + ENDIF() + EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe + WORKING_DIRECTORY ${ROOT_DIR} + RESULT_VARIABLE git_exit_code + OUTPUT_VARIABLE DESCRIBE) + IF(NOT ${git_exit_code} EQUAL 0) + MESSAGE(WARNING "git rev-parse failed, unable to include git branch.") + ELSE() + STRING(STRIP ${DESCRIBE} DESCRIBE) + ENDIF() + ENDIF() +ENDIF() + # if processing exported sources, use "revision" file if exists IF(SOURCE_DIR AND NOT DEFINED REVISION) SET(REVISION_FILE ${SOURCE_DIR}/revision) diff --git a/code/CMakeModules/OSXToolChain.cmake b/code/CMakeModules/OSXToolChain.cmake index 3169aec78..d480c13b8 100644 --- a/code/CMakeModules/OSXToolChain.cmake +++ b/code/CMakeModules/OSXToolChain.cmake @@ -1,11 +1,11 @@ # Define OSX_SDK to force a specific version such as : -DOSX_SDK=10.11 # # Example: -# cmake ../code -DCMAKE_TOOLCHAIN_FILE=../code/CMakeModules/OSXToolChain.cmake -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_SERVER=OFF -DWITH_NEL_TOOLS=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_BUILD_TYPE=Release -DWITH_RYZOM_INSTALLER=OFF -DWITH_RYZOM_PATCH=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_WARNINGS=OFF -DWITH_QT5=OFF -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_STATIC_EXTERNAL=ON -DWITH_UNIX_STRUCTURE=OFF -DWITH_INSTALL_LIBRARIES=OFF -DWITH_RYZOM_SANDBOX=OFF -DOSX_SDK=10.11 +# cmake .. -DCMAKE_TOOLCHAIN_FILE=$CMAKE_MODULE_PATH/OSXToolChain.cmake -DOSX_SDK=10.14 # Don't forget to define environment variables: # -# export MACOSX_DEPLOYMENT_TARGET=10.7 +# export MACOSX_DEPLOYMENT_TARGET=10.8 # export OSXCROSS_GCC_NO_STATIC_RUNTIME=1 # export PATH=$PATH:/home/src/osxcross/target/bin # @@ -15,18 +15,22 @@ # ./osxcross-macports install libxml2 jpeg curl libogg libvorbis freetype boost openssl zlib lua-5.3 giflib # to compile Luabind -# export CMAKE_MODULE_PATH=$HOME/shard/tools/external/cmake/modules -# cmake .. -DCMAKE_TOOLCHAIN_FILE=$HOME/ryzomcore/code/CMakeModules/OSXToolChain.cmake -DWITH_SHARED=OFF -DWITH_STATIC=ON -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_INSTALL_PREFIX=$HOME/osxcross/target/external +# cmake .. -DCMAKE_TOOLCHAIN_FILE=$CMAKE_MODULE_PATH/OSXToolChain.cmake -DWITH_SHARED=OFF -DWITH_STATIC=ON -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_INSTALL_PREFIX=$HOME/osxcross/target/external IF(DEFINED CMAKE_CROSSCOMPILING) # subsequent toolchain loading is not really needed RETURN() ENDIF() +# OSXCROSS_TARGET +# OSXCROSS_SDK + # Force the compilers to Clang for OS X +SET(OSXCROSS_HOST "x86_64-apple-darwin18") + # C -SET(CMAKE_C_COMPILER x86_64-apple-darwin15-clang) +SET(CMAKE_C_COMPILER ${OSXCROSS_HOST}-clang) SET(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") SET(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert") SET(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") @@ -34,7 +38,7 @@ SET(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros") SET(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") # C++ -SET(CMAKE_CXX_COMPILER x86_64-apple-darwin15-clang++) +SET(CMAKE_CXX_COMPILER ${OSXCROSS_HOST}-clang++) SET(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17") SET(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters") SET(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") @@ -102,8 +106,8 @@ SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}/MacOSX${OSX_SDK}.sdk) # Standard settings SET(CMAKE_SYSTEM_NAME Darwin) -SET(CMAKE_SYSTEM "Darwin-15.0.0") -SET(CMAKE_SYSTEM_VERSION "15.0.0") +SET(CMAKE_SYSTEM "Darwin-18.0.0") +SET(CMAKE_SYSTEM_VERSION "18.0.0") SET(CMAKE_SYSTEM_PROCESSOR "x86_64") SET(UNIX ON) @@ -123,9 +127,17 @@ SET(CMAKE_SYSTEM_FRAMEWORK_PATH ) # only search the OS X sdks, not the remainder of the host filesystem -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH INCLUDE(CMakeFindBinUtils) + +set(CMAKE_AR "${OSXCROSS_HOST}-ar" CACHE FILEPATH "ar") +set(CMAKE_RANLIB "${OSXCROSS_HOST}-ranlib" CACHE FILEPATH "ranlib") +set(CMAKE_INSTALL_NAME_TOOL "${OSXCROSS_HOST}-install_name_tool" CACHE FILEPATH "install_name_tool") + +set(ENV{PKG_CONFIG_LIBDIR} "${MACPORTS_ROOT_DIR}/lib/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_OSX_TOOLCHAIN_ROOT}/macports/pkgs") diff --git a/code/CMakeModules/iOSToolChain.cmake b/code/CMakeModules/iOSToolChain.cmake index 7bcb57227..37c483afb 100644 --- a/code/CMakeModules/iOSToolChain.cmake +++ b/code/CMakeModules/iOSToolChain.cmake @@ -137,23 +137,23 @@ SET(CMAKE_IOS_SIMULATOR_SYSROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Sysr IF(CMAKE_GENERATOR MATCHES Xcode) IF(${IOS_PLATFORM} STREQUAL "OS") - SET(CMAKE_SYSTEM_PROCESSOR "armv7") + SET(CMAKE_SYSTEM_PROCESSOR "arm64") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") - SET(CMAKE_SYSTEM_PROCESSOR "x86") + SET(CMAKE_SYSTEM_PROCESSOR "x86_64") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") - SET(CMAKE_SYSTEM_PROCESSOR "armv7") + SET(CMAKE_SYSTEM_PROCESSOR "arm64") ENDIF() ELSE() IF(${IOS_PLATFORM} STREQUAL "OS") SET(ARCHS armv7 arm64) - SET(CMAKE_SYSTEM_PROCESSOR "armv7") + SET(CMAKE_SYSTEM_PROCESSOR "arm64") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") - # iPhone simulator targets i386 - SET(ARCHS "i386") + # iPhone simulator targets x86_64 + SET(ARCHS "x86_64") SET(CMAKE_SYSTEM_PROCESSOR "x86") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") - SET(ARCHS armv7 arm64 i386 x86_64) - SET(CMAKE_SYSTEM_PROCESSOR "armv7") + SET(ARCHS armv7 arm64 x86_64) + SET(CMAKE_SYSTEM_PROCESSOR "arm64") ENDIF() ENDIF() diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index abe41ca1f..f8d01a0bc 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -247,6 +247,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) OPTION(WITH_ASSIMP "Use assimp exporter" OFF) + OPTION(WITH_LIBGSF "Use libgsf for max file library" OFF) ### # GUI toolkits @@ -280,6 +281,8 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_RYZOM "Build Ryzom Core." ON ) OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) OPTION(WITH_TOOLS "Build Tools" OFF) + + OPTION(WITH_RYZOM_LIVE "Use ryzom.com urls" OFF) ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) @@ -288,6 +291,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) ### OPTION(WITH_NET "Build NLNET" ON ) OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_WEB "Build WEB" ON ) OPTION(WITH_GUI "Build GUI" ON ) OPTION(WITH_PACS "Build NLPACS" ON ) OPTION(WITH_GEORGES "Build NLGEORGES" ON ) @@ -567,6 +571,11 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-DENABLE_LOGS") ENDIF() + SET(CUSTOM_FLAGS "" CACHE STRING "Custom compile flags (useful for /MPn)") + IF(NOT ${CUSTOM_FLAGS} STREQUAL "") + ADD_PLATFORM_FLAGS(${CUSTOM_FLAGS}) + ENDIF() + IF(MSVC) # Ignore default include paths ADD_PLATFORM_FLAGS("/X") diff --git a/code/config.h.cmake b/code/config.h.cmake index 69171cf68..fa4749cb2 100644 --- a/code/config.h.cmake +++ b/code/config.h.cmake @@ -27,9 +27,20 @@ #cmakedefine NL_VERSION "${NL_VERSION}" #cmakedefine NL_VERSION_RC ${NL_VERSION_RC} +#cmakedefine NL_PRODUCT_VERSION "${NL_PRODUCT_VERSION}" #cmakedefine RYZOM_VERSION "${RYZOM_VERSION}" #cmakedefine RYZOM_VERSION_RC ${RYZOM_VERSION_RC} +#cmakedefine RYZOM_PRODUCT_VERSION "${RYZOM_PRODUCT_VERSION}" + +#cmakedefine RYZOM_CLIENT_CREATE_ACCOUNT_URL "${RYZOM_CLIENT_CREATE_ACCOUNT_URL}" +#cmakedefine RYZOM_CLIENT_EDIT_ACCOUNT_URL "${RYZOM_CLIENT_EDIT_ACCOUNT_URL}" +#cmakedefine RYZOM_CLIENT_FORGET_PASSWORD_URL "${RYZOM_CLIENT_FORGET_PASSWORD_URL}" +#cmakedefine RYZOM_CLIENT_PATCH_URL "${RYZOM_CLIENT_PATCH_URL}" + +#cmakedefine RYZOM_WEBIG_MAIN_URL "${RYZOM_WEBIG_MAIN_URL}" +#cmakedefine RYZOM_WEBIG_TRUSTED_DOMAIN "${RYZOM_WEBIG_TRUSTED_DOMAIN}" + #cmakedefine AUTHOR "${AUTHOR}" #cmakedefine YEAR "${YEAR}" #cmakedefine COPYRIGHT "${COPYRIGHT}" diff --git a/code/nel/3rdparty/CMakeLists.txt b/code/nel/3rdparty/CMakeLists.txt new file mode 100644 index 000000000..bdd3e5fcd --- /dev/null +++ b/code/nel/3rdparty/CMakeLists.txt @@ -0,0 +1,2 @@ +SET(SEVENZIP_LIBRARY "nel_sevenzip") +ADD_SUBDIRECTORY(seven_zip) diff --git a/code/ryzom/client/src/seven_zip/7z.h b/code/nel/3rdparty/seven_zip/7z.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7z.h rename to code/nel/3rdparty/seven_zip/7z.h diff --git a/code/ryzom/client/src/seven_zip/7zAlloc.cpp b/code/nel/3rdparty/seven_zip/7zAlloc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zAlloc.cpp rename to code/nel/3rdparty/seven_zip/7zAlloc.c diff --git a/code/ryzom/client/src/seven_zip/7zAlloc.h b/code/nel/3rdparty/seven_zip/7zAlloc.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7zAlloc.h rename to code/nel/3rdparty/seven_zip/7zAlloc.h diff --git a/code/ryzom/client/src/seven_zip/7zArcIn.cpp b/code/nel/3rdparty/seven_zip/7zArcIn.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zArcIn.cpp rename to code/nel/3rdparty/seven_zip/7zArcIn.c diff --git a/code/ryzom/client/src/seven_zip/7zBuf.cpp b/code/nel/3rdparty/seven_zip/7zBuf.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zBuf.cpp rename to code/nel/3rdparty/seven_zip/7zBuf.c diff --git a/code/ryzom/client/src/seven_zip/7zBuf.h b/code/nel/3rdparty/seven_zip/7zBuf.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7zBuf.h rename to code/nel/3rdparty/seven_zip/7zBuf.h diff --git a/code/ryzom/client/src/seven_zip/7zBuf2.cpp b/code/nel/3rdparty/seven_zip/7zBuf2.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zBuf2.cpp rename to code/nel/3rdparty/seven_zip/7zBuf2.c diff --git a/code/ryzom/client/src/seven_zip/7zCrc.cpp b/code/nel/3rdparty/seven_zip/7zCrc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zCrc.cpp rename to code/nel/3rdparty/seven_zip/7zCrc.c diff --git a/code/ryzom/client/src/seven_zip/7zCrc.h b/code/nel/3rdparty/seven_zip/7zCrc.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7zCrc.h rename to code/nel/3rdparty/seven_zip/7zCrc.h diff --git a/code/ryzom/client/src/seven_zip/7zCrcOpt.cpp b/code/nel/3rdparty/seven_zip/7zCrcOpt.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zCrcOpt.cpp rename to code/nel/3rdparty/seven_zip/7zCrcOpt.c diff --git a/code/ryzom/client/src/seven_zip/7zDec.cpp b/code/nel/3rdparty/seven_zip/7zDec.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zDec.cpp rename to code/nel/3rdparty/seven_zip/7zDec.c diff --git a/code/ryzom/client/src/seven_zip/7zFile.cpp b/code/nel/3rdparty/seven_zip/7zFile.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zFile.cpp rename to code/nel/3rdparty/seven_zip/7zFile.c diff --git a/code/ryzom/client/src/seven_zip/7zFile.h b/code/nel/3rdparty/seven_zip/7zFile.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7zFile.h rename to code/nel/3rdparty/seven_zip/7zFile.h diff --git a/code/ryzom/client/src/seven_zip/7zStream.cpp b/code/nel/3rdparty/seven_zip/7zStream.c similarity index 100% rename from code/ryzom/client/src/seven_zip/7zStream.cpp rename to code/nel/3rdparty/seven_zip/7zStream.c diff --git a/code/ryzom/client/src/seven_zip/7zTypes.h b/code/nel/3rdparty/seven_zip/7zTypes.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7zTypes.h rename to code/nel/3rdparty/seven_zip/7zTypes.h diff --git a/code/ryzom/client/src/seven_zip/7zVersion.h b/code/nel/3rdparty/seven_zip/7zVersion.h similarity index 100% rename from code/ryzom/client/src/seven_zip/7zVersion.h rename to code/nel/3rdparty/seven_zip/7zVersion.h diff --git a/code/ryzom/client/src/seven_zip/7zVersion.rc b/code/nel/3rdparty/seven_zip/7zVersion.rc similarity index 96% rename from code/ryzom/client/src/seven_zip/7zVersion.rc rename to code/nel/3rdparty/seven_zip/7zVersion.rc index 6ed26de74..e520995dd 100644 --- a/code/ryzom/client/src/seven_zip/7zVersion.rc +++ b/code/nel/3rdparty/seven_zip/7zVersion.rc @@ -1,55 +1,55 @@ -#define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL -#define MY_VOS_NT_WINDOWS32 0x00040004L -#define MY_VOS_CE_WINDOWS32 0x00050004L - -#define MY_VFT_APP 0x00000001L -#define MY_VFT_DLL 0x00000002L - -// #include - -#ifndef MY_VERSION -#include "7zVersion.h" -#endif - -#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 - -#ifdef DEBUG -#define DBG_FL VS_FF_DEBUG -#else -#define DBG_FL 0 -#endif - -#define MY_VERSION_INFO(fileType, descr, intName, origName) \ -LANGUAGE 9, 1 \ -1 VERSIONINFO \ - FILEVERSION MY_VER \ - PRODUCTVERSION MY_VER \ - FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ - FILEFLAGS DBG_FL \ - FILEOS MY_VOS_NT_WINDOWS32 \ - FILETYPE fileType \ - FILESUBTYPE 0x0L \ -BEGIN \ - BLOCK "StringFileInfo" \ - BEGIN \ - BLOCK "040904b0" \ - BEGIN \ - VALUE "CompanyName", "Igor Pavlov" \ - VALUE "FileDescription", descr \ - VALUE "FileVersion", MY_VERSION \ - VALUE "InternalName", intName \ - VALUE "LegalCopyright", MY_COPYRIGHT \ - VALUE "OriginalFilename", origName \ - VALUE "ProductName", "7-Zip" \ - VALUE "ProductVersion", MY_VERSION \ - END \ - END \ - BLOCK "VarFileInfo" \ - BEGIN \ - VALUE "Translation", 0x409, 1200 \ - END \ -END - -#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") - -#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") +#define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL +#define MY_VOS_NT_WINDOWS32 0x00040004L +#define MY_VOS_CE_WINDOWS32 0x00050004L + +#define MY_VFT_APP 0x00000001L +#define MY_VFT_DLL 0x00000002L + +// #include + +#ifndef MY_VERSION +#include "7zVersion.h" +#endif + +#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 + +#ifdef DEBUG +#define DBG_FL VS_FF_DEBUG +#else +#define DBG_FL 0 +#endif + +#define MY_VERSION_INFO(fileType, descr, intName, origName) \ +LANGUAGE 9, 1 \ +1 VERSIONINFO \ + FILEVERSION MY_VER \ + PRODUCTVERSION MY_VER \ + FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ + FILEFLAGS DBG_FL \ + FILEOS MY_VOS_NT_WINDOWS32 \ + FILETYPE fileType \ + FILESUBTYPE 0x0L \ +BEGIN \ + BLOCK "StringFileInfo" \ + BEGIN \ + BLOCK "040904b0" \ + BEGIN \ + VALUE "CompanyName", "Igor Pavlov" \ + VALUE "FileDescription", descr \ + VALUE "FileVersion", MY_VERSION \ + VALUE "InternalName", intName \ + VALUE "LegalCopyright", MY_COPYRIGHT \ + VALUE "OriginalFilename", origName \ + VALUE "ProductName", "7-Zip" \ + VALUE "ProductVersion", MY_VERSION \ + END \ + END \ + BLOCK "VarFileInfo" \ + BEGIN \ + VALUE "Translation", 0x409, 1200 \ + END \ +END + +#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") + +#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") diff --git a/code/ryzom/client/src/seven_zip/Aes.cpp b/code/nel/3rdparty/seven_zip/Aes.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Aes.cpp rename to code/nel/3rdparty/seven_zip/Aes.c diff --git a/code/ryzom/client/src/seven_zip/Aes.h b/code/nel/3rdparty/seven_zip/Aes.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Aes.h rename to code/nel/3rdparty/seven_zip/Aes.h diff --git a/code/ryzom/client/src/seven_zip/AesOpt.cpp b/code/nel/3rdparty/seven_zip/AesOpt.c similarity index 100% rename from code/ryzom/client/src/seven_zip/AesOpt.cpp rename to code/nel/3rdparty/seven_zip/AesOpt.c diff --git a/code/ryzom/client/src/seven_zip/Alloc.cpp b/code/nel/3rdparty/seven_zip/Alloc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Alloc.cpp rename to code/nel/3rdparty/seven_zip/Alloc.c diff --git a/code/ryzom/client/src/seven_zip/Alloc.h b/code/nel/3rdparty/seven_zip/Alloc.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Alloc.h rename to code/nel/3rdparty/seven_zip/Alloc.h diff --git a/code/ryzom/client/src/seven_zip/Bcj2.cpp b/code/nel/3rdparty/seven_zip/Bcj2.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Bcj2.cpp rename to code/nel/3rdparty/seven_zip/Bcj2.c diff --git a/code/ryzom/client/src/seven_zip/Bcj2.h b/code/nel/3rdparty/seven_zip/Bcj2.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Bcj2.h rename to code/nel/3rdparty/seven_zip/Bcj2.h diff --git a/code/ryzom/client/src/seven_zip/Bcj2Enc.cpp b/code/nel/3rdparty/seven_zip/Bcj2Enc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Bcj2Enc.cpp rename to code/nel/3rdparty/seven_zip/Bcj2Enc.c diff --git a/code/ryzom/client/src/seven_zip/Bra.cpp b/code/nel/3rdparty/seven_zip/Bra.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Bra.cpp rename to code/nel/3rdparty/seven_zip/Bra.c diff --git a/code/ryzom/client/src/seven_zip/Bra.h b/code/nel/3rdparty/seven_zip/Bra.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Bra.h rename to code/nel/3rdparty/seven_zip/Bra.h diff --git a/code/ryzom/client/src/seven_zip/Bra86.cpp b/code/nel/3rdparty/seven_zip/Bra86.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Bra86.cpp rename to code/nel/3rdparty/seven_zip/Bra86.c diff --git a/code/ryzom/client/src/seven_zip/BraIA64.cpp b/code/nel/3rdparty/seven_zip/BraIA64.c similarity index 100% rename from code/ryzom/client/src/seven_zip/BraIA64.cpp rename to code/nel/3rdparty/seven_zip/BraIA64.c diff --git a/code/nel/3rdparty/seven_zip/CMakeLists.txt b/code/nel/3rdparty/seven_zip/CMakeLists.txt new file mode 100644 index 000000000..dfbf00aa2 --- /dev/null +++ b/code/nel/3rdparty/seven_zip/CMakeLists.txt @@ -0,0 +1,27 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +FILE(GLOB LIB_SRC *.cpp *.c *.h) + +LIST(REMOVE_ITEM LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/LzmaUtil.c) + +NL_TARGET_LIB(nel_sevenzip ${LIB_SRC}) +# TARGET_LINK_LIBRARIES(nel_sevenzip ${PLATFORM_LINKFLAGS}) +NL_DEFAULT_PROPS(nel_sevenzip "NeL, 3rd Party: Seven Zip") +NL_ADD_RUNTIME_FLAGS(nel_sevenzip) +NL_ADD_LIB_SUFFIX(nel_sevenzip) + +ADD_DEFINITIONS(-D_7ZIP_ST) + +IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) + INSTALL(TARGETS nel_sevenzip LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT libraries) +ENDIF() + +IF(WITH_NEL_TOOLS) + ADD_EXECUTABLE(lzma ${CMAKE_CURRENT_SOURCE_DIR}/LzmaUtil.c) + + TARGET_LINK_LIBRARIES(lzma nel_sevenzip) + NL_DEFAULT_PROPS(lzma "NeL, 3rd Party: LZMA") + NL_ADD_RUNTIME_FLAGS(lzma) + + INSTALL(TARGETS lzma RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools) +ENDIF() diff --git a/code/ryzom/client/src/seven_zip/Compiler.h b/code/nel/3rdparty/seven_zip/Compiler.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Compiler.h rename to code/nel/3rdparty/seven_zip/Compiler.h diff --git a/code/ryzom/client/src/seven_zip/CpuArch.cpp b/code/nel/3rdparty/seven_zip/CpuArch.c similarity index 100% rename from code/ryzom/client/src/seven_zip/CpuArch.cpp rename to code/nel/3rdparty/seven_zip/CpuArch.c diff --git a/code/ryzom/client/src/seven_zip/CpuArch.h b/code/nel/3rdparty/seven_zip/CpuArch.h similarity index 100% rename from code/ryzom/client/src/seven_zip/CpuArch.h rename to code/nel/3rdparty/seven_zip/CpuArch.h diff --git a/code/ryzom/client/src/seven_zip/Delta.cpp b/code/nel/3rdparty/seven_zip/Delta.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Delta.cpp rename to code/nel/3rdparty/seven_zip/Delta.c diff --git a/code/ryzom/client/src/seven_zip/Delta.h b/code/nel/3rdparty/seven_zip/Delta.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Delta.h rename to code/nel/3rdparty/seven_zip/Delta.h diff --git a/code/nel/3rdparty/seven_zip/DllSecur.c b/code/nel/3rdparty/seven_zip/DllSecur.c new file mode 100644 index 000000000..5ea108ab8 --- /dev/null +++ b/code/nel/3rdparty/seven_zip/DllSecur.c @@ -0,0 +1,108 @@ +/* DllSecur.c -- DLL loading security +2018-02-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#ifdef _WIN32 + +#include + +#include "DllSecur.h" + +#ifndef UNDER_CE + +typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags); + +#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400 +#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800 + +static const char * const g_Dlls = + #ifndef _CONSOLE + "UXTHEME\0" + #endif + "USERENV\0" + "SETUPAPI\0" + "APPHELP\0" + "PROPSYS\0" + "DWMAPI\0" + "CRYPTBASE\0" + "OLEACC\0" + "CLBCATQ\0" + "VERSION\0" + ; + +#endif + +void My_SetDefaultDllDirectories() +{ + #ifndef UNDER_CE + + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + GetVersionEx(&vi); + if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) + { + Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) + GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); + if (setDllDirs) + if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) + return; + } + + #endif +} + + +void LoadSecurityDlls() +{ + #ifndef UNDER_CE + + wchar_t buf[MAX_PATH + 100]; + + { + // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) + { + Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) + GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); + if (setDllDirs) + if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) + return; + } + } + + { + unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); + if (len == 0 || len > MAX_PATH) + return; + } + { + const char *dll; + unsigned pos = (unsigned)lstrlenW(buf); + + if (buf[pos - 1] != '\\') + buf[pos++] = '\\'; + + for (dll = g_Dlls; dll[0] != 0;) + { + unsigned k = 0; + for (;;) + { + char c = *dll++; + buf[pos + k] = (Byte)c; + k++; + if (c == 0) + break; + } + + lstrcatW(buf, L".dll"); + LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + } + } + + #endif +} + +#endif diff --git a/code/nel/3rdparty/seven_zip/DllSecur.h b/code/nel/3rdparty/seven_zip/DllSecur.h new file mode 100644 index 000000000..e2a049ad2 --- /dev/null +++ b/code/nel/3rdparty/seven_zip/DllSecur.h @@ -0,0 +1,20 @@ +/* DllSecur.h -- DLL loading for security +2018-02-19 : Igor Pavlov : Public domain */ + +#ifndef __DLL_SECUR_H +#define __DLL_SECUR_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#ifdef _WIN32 + +void My_SetDefaultDllDirectories(); +void LoadSecurityDlls(); + +#endif + +EXTERN_C_END + +#endif diff --git a/code/ryzom/client/src/seven_zip/LzFind.cpp b/code/nel/3rdparty/seven_zip/LzFind.c similarity index 100% rename from code/ryzom/client/src/seven_zip/LzFind.cpp rename to code/nel/3rdparty/seven_zip/LzFind.c diff --git a/code/ryzom/client/src/seven_zip/LzFind.h b/code/nel/3rdparty/seven_zip/LzFind.h similarity index 100% rename from code/ryzom/client/src/seven_zip/LzFind.h rename to code/nel/3rdparty/seven_zip/LzFind.h diff --git a/code/ryzom/client/src/seven_zip/LzHash.h b/code/nel/3rdparty/seven_zip/LzHash.h similarity index 100% rename from code/ryzom/client/src/seven_zip/LzHash.h rename to code/nel/3rdparty/seven_zip/LzHash.h diff --git a/code/ryzom/client/src/seven_zip/Lzma2Dec.cpp b/code/nel/3rdparty/seven_zip/Lzma2Dec.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Lzma2Dec.cpp rename to code/nel/3rdparty/seven_zip/Lzma2Dec.c diff --git a/code/ryzom/client/src/seven_zip/Lzma2Dec.h b/code/nel/3rdparty/seven_zip/Lzma2Dec.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Lzma2Dec.h rename to code/nel/3rdparty/seven_zip/Lzma2Dec.h diff --git a/code/nel/3rdparty/seven_zip/Lzma2DecMt.c b/code/nel/3rdparty/seven_zip/Lzma2DecMt.c new file mode 100644 index 000000000..988643d95 --- /dev/null +++ b/code/nel/3rdparty/seven_zip/Lzma2DecMt.c @@ -0,0 +1,1082 @@ +/* Lzma2DecMt.c -- LZMA2 Decoder Multi-thread +2019-02-02 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +// #define SHOW_DEBUG_INFO + +#ifdef SHOW_DEBUG_INFO +#include +#endif + +#ifdef SHOW_DEBUG_INFO +#define PRF(x) x +#else +#define PRF(x) +#endif + +#define PRF_STR(s) PRF(printf("\n" s "\n")) +#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) +#define PRF_STR_INT_2(s, d1, d2) PRF(printf("\n" s " %d %d\n", (unsigned)d1, (unsigned)d2)) + +// #define _7ZIP_ST + +#include "Alloc.h" + +#include "Lzma2Dec.h" +#include "Lzma2DecMt.h" + +#ifndef _7ZIP_ST +#include "MtDec.h" +#endif + + +#define LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT (1 << 28) + +void Lzma2DecMtProps_Init(CLzma2DecMtProps *p) +{ + p->inBufSize_ST = 1 << 20; + p->outStep_ST = 1 << 20; + + #ifndef _7ZIP_ST + p->numThreads = 1; + p->inBufSize_MT = 1 << 18; + p->outBlockMax = LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT; + p->inBlockMax = p->outBlockMax + p->outBlockMax / 16; + #endif +} + + + +#ifndef _7ZIP_ST + +/* ---------- CLzma2DecMtThread ---------- */ + +typedef struct +{ + CLzma2Dec dec; + Byte dec_created; + Byte needInit; + + Byte *outBuf; + size_t outBufSize; + + EMtDecParseState state; + ELzma2ParseStatus parseStatus; + + size_t inPreSize; + size_t outPreSize; + + size_t inCodeSize; + size_t outCodeSize; + SRes codeRes; + + CAlignOffsetAlloc alloc; + + Byte mtPad[1 << 7]; +} CLzma2DecMtThread; + +#endif + + +/* ---------- CLzma2DecMt ---------- */ + +typedef struct +{ + // ISzAllocPtr alloc; + ISzAllocPtr allocMid; + + CAlignOffsetAlloc alignOffsetAlloc; + CLzma2DecMtProps props; + Byte prop; + + ISeqInStream *inStream; + ISeqOutStream *outStream; + ICompressProgress *progress; + + BoolInt finishMode; + BoolInt outSize_Defined; + UInt64 outSize; + + UInt64 outProcessed; + UInt64 inProcessed; + BoolInt readWasFinished; + SRes readRes; + + Byte *inBuf; + size_t inBufSize; + Byte dec_created; + CLzma2Dec dec; + + size_t inPos; + size_t inLim; + + #ifndef _7ZIP_ST + UInt64 outProcessed_Parse; + BoolInt mtc_WasConstructed; + CMtDec mtc; + CLzma2DecMtThread coders[MTDEC__THREADS_MAX]; + #endif + +} CLzma2DecMt; + + + +CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid) +{ + CLzma2DecMt *p = (CLzma2DecMt *)ISzAlloc_Alloc(alloc, sizeof(CLzma2DecMt)); + if (!p) + return NULL; + + // p->alloc = alloc; + p->allocMid = allocMid; + + AlignOffsetAlloc_CreateVTable(&p->alignOffsetAlloc); + p->alignOffsetAlloc.numAlignBits = 7; + p->alignOffsetAlloc.offset = 0; + p->alignOffsetAlloc.baseAlloc = alloc; + + p->inBuf = NULL; + p->inBufSize = 0; + p->dec_created = False; + + // Lzma2DecMtProps_Init(&p->props); + + #ifndef _7ZIP_ST + p->mtc_WasConstructed = False; + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CLzma2DecMtThread *t = &p->coders[i]; + t->dec_created = False; + t->outBuf = NULL; + t->outBufSize = 0; + } + } + #endif + + return p; +} + + +#ifndef _7ZIP_ST + +static void Lzma2DecMt_FreeOutBufs(CLzma2DecMt *p) +{ + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CLzma2DecMtThread *t = &p->coders[i]; + if (t->outBuf) + { + ISzAlloc_Free(p->allocMid, t->outBuf); + t->outBuf = NULL; + t->outBufSize = 0; + } + } +} + +#endif + + +static void Lzma2DecMt_FreeSt(CLzma2DecMt *p) +{ + if (p->dec_created) + { + Lzma2Dec_Free(&p->dec, &p->alignOffsetAlloc.vt); + p->dec_created = False; + } + if (p->inBuf) + { + ISzAlloc_Free(p->allocMid, p->inBuf); + p->inBuf = NULL; + } + p->inBufSize = 0; +} + + +void Lzma2DecMt_Destroy(CLzma2DecMtHandle pp) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + + Lzma2DecMt_FreeSt(p); + + #ifndef _7ZIP_ST + + if (p->mtc_WasConstructed) + { + MtDec_Destruct(&p->mtc); + p->mtc_WasConstructed = False; + } + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CLzma2DecMtThread *t = &p->coders[i]; + if (t->dec_created) + { + // we don't need to free dict here + Lzma2Dec_FreeProbs(&t->dec, &t->alloc.vt); // p->alloc !!! + t->dec_created = False; + } + } + } + Lzma2DecMt_FreeOutBufs(p); + + #endif + + ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); +} + + + +#ifndef _7ZIP_ST + +static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc) +{ + CLzma2DecMt *me = (CLzma2DecMt *)obj; + CLzma2DecMtThread *t = &me->coders[coderIndex]; + + PRF_STR_INT_2("Parse", coderIndex, cc->srcSize); + + cc->state = MTDEC_PARSE_CONTINUE; + + if (cc->startCall) + { + if (!t->dec_created) + { + Lzma2Dec_Construct(&t->dec); + t->dec_created = True; + AlignOffsetAlloc_CreateVTable(&t->alloc); + { + /* (1 << 12) is expected size of one way in data cache. + We optimize alignment for cache line size of 128 bytes and smaller */ + const unsigned kNumAlignBits = 12; + const unsigned kNumCacheLineBits = 7; /* <= kNumAlignBits */ + t->alloc.numAlignBits = kNumAlignBits; + t->alloc.offset = ((UInt32)coderIndex * ((1 << 11) + (1 << 8) + (1 << 6))) & ((1 << kNumAlignBits) - (1 << kNumCacheLineBits)); + t->alloc.baseAlloc = me->alignOffsetAlloc.baseAlloc; + } + } + Lzma2Dec_Init(&t->dec); + + t->inPreSize = 0; + t->outPreSize = 0; + // t->blockWasFinished = False; + // t->finishedWithMark = False; + t->parseStatus = (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED; + t->state = MTDEC_PARSE_CONTINUE; + + t->inCodeSize = 0; + t->outCodeSize = 0; + t->codeRes = SZ_OK; + + // (cc->srcSize == 0) is allowed + } + + { + ELzma2ParseStatus status; + BoolInt overflow; + UInt32 unpackRem = 0; + + int checkFinishBlock = True; + size_t limit = me->props.outBlockMax; + if (me->outSize_Defined) + { + UInt64 rem = me->outSize - me->outProcessed_Parse; + if (limit >= rem) + { + limit = (size_t)rem; + if (!me->finishMode) + checkFinishBlock = False; + } + } + + // checkFinishBlock = False, if we want to decode partial data + // that must be finished at position <= outBlockMax. + + { + const SizeT srcOrig = cc->srcSize; + SizeT srcSize_Point = 0; + SizeT dicPos_Point = 0; + + cc->srcSize = 0; + overflow = False; + + for (;;) + { + SizeT srcCur = srcOrig - cc->srcSize; + + status = Lzma2Dec_Parse(&t->dec, + limit - t->dec.decoder.dicPos, + cc->src + cc->srcSize, &srcCur, + checkFinishBlock); + + cc->srcSize += srcCur; + + if (status == LZMA2_PARSE_STATUS_NEW_CHUNK) + { + if (t->dec.unpackSize > me->props.outBlockMax - t->dec.decoder.dicPos) + { + overflow = True; + break; + } + continue; + } + + if (status == LZMA2_PARSE_STATUS_NEW_BLOCK) + { + if (t->dec.decoder.dicPos == 0) + continue; + // we decode small blocks in one thread + if (t->dec.decoder.dicPos >= (1 << 14)) + break; + dicPos_Point = t->dec.decoder.dicPos; + srcSize_Point = cc->srcSize; + continue; + } + + if ((int)status == LZMA_STATUS_NOT_FINISHED && checkFinishBlock + // && limit == t->dec.decoder.dicPos + // && limit == me->props.outBlockMax + ) + { + overflow = True; + break; + } + + unpackRem = Lzma2Dec_GetUnpackExtra(&t->dec); + break; + } + + if (dicPos_Point != 0 + && (int)status != LZMA2_PARSE_STATUS_NEW_BLOCK + && (int)status != LZMA_STATUS_FINISHED_WITH_MARK + && (int)status != LZMA_STATUS_NOT_SPECIFIED) + { + // we revert to latest newBlock state + status = LZMA2_PARSE_STATUS_NEW_BLOCK; + unpackRem = 0; + t->dec.decoder.dicPos = dicPos_Point; + cc->srcSize = srcSize_Point; + overflow = False; + } + } + + t->inPreSize += cc->srcSize; + t->parseStatus = status; + + if (overflow) + cc->state = MTDEC_PARSE_OVERFLOW; + else + { + size_t dicPos = t->dec.decoder.dicPos; + + if ((int)status != LZMA_STATUS_NEEDS_MORE_INPUT) + { + if (status == LZMA2_PARSE_STATUS_NEW_BLOCK) + { + cc->state = MTDEC_PARSE_NEW; + cc->srcSize--; // we don't need control byte of next block + t->inPreSize--; + } + else + { + cc->state = MTDEC_PARSE_END; + if ((int)status != LZMA_STATUS_FINISHED_WITH_MARK) + { + // (status == LZMA_STATUS_NOT_SPECIFIED) + // (status == LZMA_STATUS_NOT_FINISHED) + if (unpackRem != 0) + { + /* we also reserve space for max possible number of output bytes of current LZMA chunk */ + SizeT rem = limit - dicPos; + if (rem > unpackRem) + rem = unpackRem; + dicPos += rem; + } + } + } + + me->outProcessed_Parse += dicPos; + } + + cc->outPos = dicPos; + t->outPreSize = (size_t)dicPos; + } + + t->state = cc->state; + return; + } +} + + +static SRes Lzma2DecMt_MtCallback_PreCode(void *pp, unsigned coderIndex) +{ + CLzma2DecMt *me = (CLzma2DecMt *)pp; + CLzma2DecMtThread *t = &me->coders[coderIndex]; + Byte *dest = t->outBuf; + + if (t->inPreSize == 0) + { + t->codeRes = SZ_ERROR_DATA; + return t->codeRes; + } + + if (!dest || t->outBufSize < t->outPreSize) + { + if (dest) + { + ISzAlloc_Free(me->allocMid, dest); + t->outBuf = NULL; + t->outBufSize = 0; + } + + dest = (Byte *)ISzAlloc_Alloc(me->allocMid, t->outPreSize + // + (1 << 28) + ); + // Sleep(200); + if (!dest) + return SZ_ERROR_MEM; + t->outBuf = dest; + t->outBufSize = t->outPreSize; + } + + t->dec.decoder.dic = dest; + t->dec.decoder.dicBufSize = t->outPreSize; + + t->needInit = True; + + return Lzma2Dec_AllocateProbs(&t->dec, me->prop, &t->alloc.vt); // alloc.vt +} + + +static SRes Lzma2DecMt_MtCallback_Code(void *pp, unsigned coderIndex, + const Byte *src, size_t srcSize, int srcFinished, + // int finished, int blockFinished, + UInt64 *inCodePos, UInt64 *outCodePos, int *stop) +{ + CLzma2DecMt *me = (CLzma2DecMt *)pp; + CLzma2DecMtThread *t = &me->coders[coderIndex]; + + UNUSED_VAR(srcFinished) + + PRF_STR_INT_2("Code", coderIndex, srcSize); + + *inCodePos = t->inCodeSize; + *outCodePos = 0; + *stop = True; + + if (t->needInit) + { + Lzma2Dec_Init(&t->dec); + t->needInit = False; + } + + { + ELzmaStatus status; + size_t srcProcessed = srcSize; + BoolInt blockWasFinished = + ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK + || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK); + + SRes res = Lzma2Dec_DecodeToDic(&t->dec, + t->outPreSize, + src, &srcProcessed, + blockWasFinished ? LZMA_FINISH_END : LZMA_FINISH_ANY, + &status); + + t->codeRes = res; + + t->inCodeSize += srcProcessed; + *inCodePos = t->inCodeSize; + t->outCodeSize = t->dec.decoder.dicPos; + *outCodePos = t->dec.decoder.dicPos; + + if (res != SZ_OK) + return res; + + if (srcProcessed == srcSize) + *stop = False; + + if (blockWasFinished) + { + if (srcSize != srcProcessed) + return SZ_ERROR_FAIL; + + if (t->inPreSize == t->inCodeSize) + { + if (t->outPreSize != t->outCodeSize) + return SZ_ERROR_FAIL; + *stop = True; + } + } + else + { + if (t->outPreSize == t->outCodeSize) + *stop = True; + } + + return SZ_OK; + } +} + + +#define LZMA2DECMT_STREAM_WRITE_STEP (1 << 24) + +static SRes Lzma2DecMt_MtCallback_Write(void *pp, unsigned coderIndex, + BoolInt needWriteToStream, + const Byte *src, size_t srcSize, + BoolInt *needContinue, BoolInt *canRecode) +{ + CLzma2DecMt *me = (CLzma2DecMt *)pp; + const CLzma2DecMtThread *t = &me->coders[coderIndex]; + size_t size = t->outCodeSize; + const Byte *data = t->outBuf; + BoolInt needContinue2 = True; + + PRF_STR_INT_2("Write", coderIndex, srcSize); + + *needContinue = False; + *canRecode = True; + UNUSED_VAR(src) + UNUSED_VAR(srcSize) + + if ( + // t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK + t->state == MTDEC_PARSE_OVERFLOW + || t->state == MTDEC_PARSE_END) + needContinue2 = False; + + + if (!needWriteToStream) + return SZ_OK; + + me->mtc.inProcessed += t->inCodeSize; + + if (t->codeRes == SZ_OK) + if ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK + || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK) + if (t->outPreSize != t->outCodeSize + || t->inPreSize != t->inCodeSize) + return SZ_ERROR_FAIL; + + *canRecode = False; + + if (me->outStream) + { + for (;;) + { + size_t cur = size; + size_t written; + if (cur > LZMA2DECMT_STREAM_WRITE_STEP) + cur = LZMA2DECMT_STREAM_WRITE_STEP; + + written = ISeqOutStream_Write(me->outStream, data, cur); + + me->outProcessed += written; + // me->mtc.writtenTotal += written; + if (written != cur) + return SZ_ERROR_WRITE; + data += cur; + size -= cur; + if (size == 0) + { + *needContinue = needContinue2; + return SZ_OK; + } + RINOK(MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0)); + } + } + + return SZ_ERROR_FAIL; + /* + if (size > me->outBufSize) + return SZ_ERROR_OUTPUT_EOF; + memcpy(me->outBuf, data, size); + me->outBufSize -= size; + me->outBuf += size; + *needContinue = needContinue2; + return SZ_OK; + */ +} + +#endif + + +static SRes Lzma2Dec_Prepare_ST(CLzma2DecMt *p) +{ + if (!p->dec_created) + { + Lzma2Dec_Construct(&p->dec); + p->dec_created = True; + } + + RINOK(Lzma2Dec_Allocate(&p->dec, p->prop, &p->alignOffsetAlloc.vt)); + + if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) + { + ISzAlloc_Free(p->allocMid, p->inBuf); + p->inBufSize = 0; + p->inBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.inBufSize_ST); + if (!p->inBuf) + return SZ_ERROR_MEM; + p->inBufSize = p->props.inBufSize_ST; + } + + Lzma2Dec_Init(&p->dec); + + return SZ_OK; +} + + +static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p + #ifndef _7ZIP_ST + , BoolInt tMode + #endif + ) +{ + SizeT wrPos; + size_t inPos, inLim; + const Byte *inData; + UInt64 inPrev, outPrev; + + CLzma2Dec *dec; + + #ifndef _7ZIP_ST + if (tMode) + { + Lzma2DecMt_FreeOutBufs(p); + tMode = MtDec_PrepareRead(&p->mtc); + } + #endif + + RINOK(Lzma2Dec_Prepare_ST(p)); + + dec = &p->dec; + + inPrev = p->inProcessed; + outPrev = p->outProcessed; + + inPos = 0; + inLim = 0; + inData = NULL; + wrPos = dec->decoder.dicPos; + + for (;;) + { + SizeT dicPos; + SizeT size; + ELzmaFinishMode finishMode; + SizeT inProcessed; + ELzmaStatus status; + SRes res; + + SizeT outProcessed; + BoolInt outFinished; + BoolInt needStop; + + if (inPos == inLim) + { + #ifndef _7ZIP_ST + if (tMode) + { + inData = MtDec_Read(&p->mtc, &inLim); + inPos = 0; + if (inData) + continue; + tMode = False; + inLim = 0; + } + #endif + + if (!p->readWasFinished) + { + inPos = 0; + inLim = p->inBufSize; + inData = p->inBuf; + p->readRes = ISeqInStream_Read(p->inStream, (void *)inData, &inLim); + // p->readProcessed += inLim; + // inLim -= 5; p->readWasFinished = True; // for test + if (inLim == 0 || p->readRes != SZ_OK) + p->readWasFinished = True; + } + } + + dicPos = dec->decoder.dicPos; + { + SizeT next = dec->decoder.dicBufSize; + if (next - wrPos > p->props.outStep_ST) + next = wrPos + p->props.outStep_ST; + size = next - dicPos; + } + + finishMode = LZMA_FINISH_ANY; + if (p->outSize_Defined) + { + const UInt64 rem = p->outSize - p->outProcessed; + if (size >= rem) + { + size = (SizeT)rem; + if (p->finishMode) + finishMode = LZMA_FINISH_END; + } + } + + inProcessed = inLim - inPos; + + res = Lzma2Dec_DecodeToDic(dec, dicPos + size, inData + inPos, &inProcessed, finishMode, &status); + + inPos += inProcessed; + p->inProcessed += inProcessed; + outProcessed = dec->decoder.dicPos - dicPos; + p->outProcessed += outProcessed; + + outFinished = (p->outSize_Defined && p->outSize <= p->outProcessed); + + needStop = (res != SZ_OK + || (inProcessed == 0 && outProcessed == 0) + || status == LZMA_STATUS_FINISHED_WITH_MARK + || (!p->finishMode && outFinished)); + + if (needStop || outProcessed >= size) + { + SRes res2; + { + size_t writeSize = dec->decoder.dicPos - wrPos; + size_t written = ISeqOutStream_Write(p->outStream, dec->decoder.dic + wrPos, writeSize); + res2 = (written == writeSize) ? SZ_OK : SZ_ERROR_WRITE; + } + + if (dec->decoder.dicPos == dec->decoder.dicBufSize) + dec->decoder.dicPos = 0; + wrPos = dec->decoder.dicPos; + + RINOK(res2); + + if (needStop) + { + if (res != SZ_OK) + return res; + + if (status == LZMA_STATUS_FINISHED_WITH_MARK) + { + if (p->finishMode) + { + if (p->outSize_Defined && p->outSize != p->outProcessed) + return SZ_ERROR_DATA; + } + return SZ_OK; + } + + if (!p->finishMode && outFinished) + return SZ_OK; + + if (status == LZMA_STATUS_NEEDS_MORE_INPUT) + return SZ_ERROR_INPUT_EOF; + + return SZ_ERROR_DATA; + } + } + + if (p->progress) + { + UInt64 inDelta = p->inProcessed - inPrev; + UInt64 outDelta = p->outProcessed - outPrev; + if (inDelta >= (1 << 22) || outDelta >= (1 << 22)) + { + RINOK(ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed)); + inPrev = p->inProcessed; + outPrev = p->outProcessed; + } + } + } +} + + + +SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp, + Byte prop, + const CLzma2DecMtProps *props, + ISeqOutStream *outStream, const UInt64 *outDataSize, int finishMode, + // Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + // const Byte *inData, size_t inDataSize, + UInt64 *inProcessed, + // UInt64 *outProcessed, + int *isMT, + ICompressProgress *progress) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + #ifndef _7ZIP_ST + BoolInt tMode; + #endif + + *inProcessed = 0; + + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + + p->prop = prop; + p->props = *props; + + p->inStream = inStream; + p->outStream = outStream; + p->progress = progress; + + p->outSize = 0; + p->outSize_Defined = False; + if (outDataSize) + { + p->outSize_Defined = True; + p->outSize = *outDataSize; + } + p->finishMode = finishMode; + + p->outProcessed = 0; + p->inProcessed = 0; + + p->readWasFinished = False; + + *isMT = False; + + + #ifndef _7ZIP_ST + + tMode = False; + + // p->mtc.parseRes = SZ_OK; + + // p->mtc.numFilledThreads = 0; + // p->mtc.crossStart = 0; + // p->mtc.crossEnd = 0; + // p->mtc.allocError_for_Read_BlockIndex = 0; + // p->mtc.isAllocError = False; + + if (p->props.numThreads > 1) + { + IMtDecCallback vt; + + Lzma2DecMt_FreeSt(p); + + p->outProcessed_Parse = 0; + + if (!p->mtc_WasConstructed) + { + p->mtc_WasConstructed = True; + MtDec_Construct(&p->mtc); + } + + p->mtc.progress = progress; + p->mtc.inStream = inStream; + + // p->outBuf = NULL; + // p->outBufSize = 0; + /* + if (!outStream) + { + // p->outBuf = outBuf; + // p->outBufSize = *outBufSize; + // *outBufSize = 0; + return SZ_ERROR_PARAM; + } + */ + + // p->mtc.inBlockMax = p->props.inBlockMax; + p->mtc.alloc = &p->alignOffsetAlloc.vt; + // p->alignOffsetAlloc.baseAlloc; + // p->mtc.inData = inData; + // p->mtc.inDataSize = inDataSize; + p->mtc.mtCallback = &vt; + p->mtc.mtCallbackObject = p; + + p->mtc.inBufSize = p->props.inBufSize_MT; + + p->mtc.numThreadsMax = p->props.numThreads; + + *isMT = True; + + vt.Parse = Lzma2DecMt_MtCallback_Parse; + vt.PreCode = Lzma2DecMt_MtCallback_PreCode; + vt.Code = Lzma2DecMt_MtCallback_Code; + vt.Write = Lzma2DecMt_MtCallback_Write; + + { + BoolInt needContinue = False; + + SRes res = MtDec_Code(&p->mtc); + + /* + if (!outStream) + *outBufSize = p->outBuf - outBuf; + */ + + *inProcessed = p->mtc.inProcessed; + + needContinue = False; + + if (res == SZ_OK) + { + if (p->mtc.mtProgress.res != SZ_OK) + res = p->mtc.mtProgress.res; + else + needContinue = p->mtc.needContinue; + } + + if (!needContinue) + { + if (res == SZ_OK) + return p->mtc.readRes; + return res; + } + + tMode = True; + p->readRes = p->mtc.readRes; + p->readWasFinished = p->mtc.readWasFinished; + p->inProcessed = p->mtc.inProcessed; + + PRF_STR("----- decoding ST -----"); + } + } + + #endif + + + *isMT = False; + + { + SRes res = Lzma2Dec_Decode_ST(p + #ifndef _7ZIP_ST + , tMode + #endif + ); + + *inProcessed = p->inProcessed; + + // res = SZ_OK; // for test + if (res == SZ_OK && p->readRes != SZ_OK) + res = p->readRes; + + /* + #ifndef _7ZIP_ST + if (res == SZ_OK && tMode && p->mtc.parseRes != SZ_OK) + res = p->mtc.parseRes; + #endif + */ + + return res; + } +} + + +/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ + +SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, + Byte prop, + const CLzma2DecMtProps *props, + const UInt64 *outDataSize, int finishMode, + ISeqInStream *inStream) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + + p->prop = prop; + p->props = *props; + + p->inStream = inStream; + + p->outSize = 0; + p->outSize_Defined = False; + if (outDataSize) + { + p->outSize_Defined = True; + p->outSize = *outDataSize; + } + p->finishMode = finishMode; + + p->outProcessed = 0; + p->inProcessed = 0; + + p->inPos = 0; + p->inLim = 0; + + return Lzma2Dec_Prepare_ST(p); +} + + +SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, + Byte *data, size_t *outSize, + UInt64 *inStreamProcessed) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + ELzmaFinishMode finishMode; + SRes readRes; + size_t size = *outSize; + + *outSize = 0; + *inStreamProcessed = 0; + + finishMode = LZMA_FINISH_ANY; + if (p->outSize_Defined) + { + const UInt64 rem = p->outSize - p->outProcessed; + if (size >= rem) + { + size = (size_t)rem; + if (p->finishMode) + finishMode = LZMA_FINISH_END; + } + } + + readRes = SZ_OK; + + for (;;) + { + SizeT inCur; + SizeT outCur; + ELzmaStatus status; + SRes res; + + if (p->inPos == p->inLim && readRes == SZ_OK) + { + p->inPos = 0; + p->inLim = p->props.inBufSize_ST; + readRes = ISeqInStream_Read(p->inStream, p->inBuf, &p->inLim); + } + + inCur = p->inLim - p->inPos; + outCur = size; + + res = Lzma2Dec_DecodeToBuf(&p->dec, data, &outCur, + p->inBuf + p->inPos, &inCur, finishMode, &status); + + p->inPos += inCur; + p->inProcessed += inCur; + *inStreamProcessed += inCur; + p->outProcessed += outCur; + *outSize += outCur; + size -= outCur; + data += outCur; + + if (res != 0) + return res; + + /* + if (status == LZMA_STATUS_FINISHED_WITH_MARK) + return readRes; + + if (size == 0 && status != LZMA_STATUS_NEEDS_MORE_INPUT) + { + if (p->finishMode && p->outSize_Defined && p->outProcessed >= p->outSize) + return SZ_ERROR_DATA; + return readRes; + } + */ + + if (inCur == 0 && outCur == 0) + return readRes; + } +} diff --git a/code/nel/3rdparty/seven_zip/Lzma2DecMt.h b/code/nel/3rdparty/seven_zip/Lzma2DecMt.h new file mode 100644 index 000000000..7791c310b --- /dev/null +++ b/code/nel/3rdparty/seven_zip/Lzma2DecMt.h @@ -0,0 +1,79 @@ +/* Lzma2DecMt.h -- LZMA2 Decoder Multi-thread +2018-02-17 : Igor Pavlov : Public domain */ + +#ifndef __LZMA2_DEC_MT_H +#define __LZMA2_DEC_MT_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +typedef struct +{ + size_t inBufSize_ST; + size_t outStep_ST; + + #ifndef _7ZIP_ST + unsigned numThreads; + size_t inBufSize_MT; + size_t outBlockMax; + size_t inBlockMax; + #endif +} CLzma2DecMtProps; + +/* init to single-thread mode */ +void Lzma2DecMtProps_Init(CLzma2DecMtProps *p); + + +/* ---------- CLzma2DecMtHandle Interface ---------- */ + +/* Lzma2DecMt_ * functions can return the following exit codes: +SRes: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater in props + SZ_ERROR_WRITE - ISeqOutStream write callback error + // SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output + SZ_ERROR_PROGRESS - some break from progress callback + SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) +*/ + +typedef void * CLzma2DecMtHandle; + +CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid); +void Lzma2DecMt_Destroy(CLzma2DecMtHandle p); + +SRes Lzma2DecMt_Decode(CLzma2DecMtHandle p, + Byte prop, + const CLzma2DecMtProps *props, + ISeqOutStream *outStream, + const UInt64 *outDataSize, // NULL means undefined + int finishMode, // 0 - partial unpacking is allowed, 1 - if lzma2 stream must be finished + // Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + // const Byte *inData, size_t inDataSize, + + // out variables: + UInt64 *inProcessed, + int *isMT, /* out: (*isMT == 0), if single thread decoding was used */ + + // UInt64 *outProcessed, + ICompressProgress *progress); + + +/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ + +SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, + Byte prop, + const CLzma2DecMtProps *props, + const UInt64 *outDataSize, int finishMode, + ISeqInStream *inStream); + +SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, + Byte *data, size_t *outSize, + UInt64 *inStreamProcessed); + + +EXTERN_C_END + +#endif diff --git a/code/ryzom/client/src/seven_zip/Lzma2Enc.cpp b/code/nel/3rdparty/seven_zip/Lzma2Enc.c similarity index 99% rename from code/ryzom/client/src/seven_zip/Lzma2Enc.cpp rename to code/nel/3rdparty/seven_zip/Lzma2Enc.c index 9af0622b0..5c1ad4931 100644 --- a/code/ryzom/client/src/seven_zip/Lzma2Enc.cpp +++ b/code/nel/3rdparty/seven_zip/Lzma2Enc.c @@ -5,7 +5,7 @@ #include -#define _7ZIP_ST +/* #define _7ZIP_ST */ #include "Lzma2Enc.h" diff --git a/code/ryzom/client/src/seven_zip/Lzma2Enc.h b/code/nel/3rdparty/seven_zip/Lzma2Enc.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Lzma2Enc.h rename to code/nel/3rdparty/seven_zip/Lzma2Enc.h diff --git a/code/ryzom/client/src/seven_zip/Lzma86.h b/code/nel/3rdparty/seven_zip/Lzma86.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Lzma86.h rename to code/nel/3rdparty/seven_zip/Lzma86.h diff --git a/code/ryzom/client/src/seven_zip/Lzma86Dec.cpp b/code/nel/3rdparty/seven_zip/Lzma86Dec.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Lzma86Dec.cpp rename to code/nel/3rdparty/seven_zip/Lzma86Dec.c diff --git a/code/ryzom/client/src/seven_zip/Lzma86Enc.cpp b/code/nel/3rdparty/seven_zip/Lzma86Enc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Lzma86Enc.cpp rename to code/nel/3rdparty/seven_zip/Lzma86Enc.c diff --git a/code/ryzom/client/src/seven_zip/LzmaDec.cpp b/code/nel/3rdparty/seven_zip/LzmaDec.c similarity index 100% rename from code/ryzom/client/src/seven_zip/LzmaDec.cpp rename to code/nel/3rdparty/seven_zip/LzmaDec.c diff --git a/code/ryzom/client/src/seven_zip/LzmaDec.h b/code/nel/3rdparty/seven_zip/LzmaDec.h similarity index 100% rename from code/ryzom/client/src/seven_zip/LzmaDec.h rename to code/nel/3rdparty/seven_zip/LzmaDec.h diff --git a/code/ryzom/client/src/seven_zip/LzmaEnc.cpp b/code/nel/3rdparty/seven_zip/LzmaEnc.c similarity index 99% rename from code/ryzom/client/src/seven_zip/LzmaEnc.cpp rename to code/nel/3rdparty/seven_zip/LzmaEnc.c index 54d0d0507..46a0db000 100644 --- a/code/ryzom/client/src/seven_zip/LzmaEnc.cpp +++ b/code/nel/3rdparty/seven_zip/LzmaEnc.c @@ -5,8 +5,6 @@ #include -#define _7ZIP_ST - /* #define SHOW_STAT */ /* #define SHOW_STAT2 */ diff --git a/code/ryzom/client/src/seven_zip/LzmaEnc.h b/code/nel/3rdparty/seven_zip/LzmaEnc.h similarity index 100% rename from code/ryzom/client/src/seven_zip/LzmaEnc.h rename to code/nel/3rdparty/seven_zip/LzmaEnc.h diff --git a/code/ryzom/client/src/seven_zip/LzmaLib.cpp b/code/nel/3rdparty/seven_zip/LzmaLib.c similarity index 100% rename from code/ryzom/client/src/seven_zip/LzmaLib.cpp rename to code/nel/3rdparty/seven_zip/LzmaLib.c diff --git a/code/ryzom/client/src/seven_zip/LzmaLib.h b/code/nel/3rdparty/seven_zip/LzmaLib.h similarity index 100% rename from code/ryzom/client/src/seven_zip/LzmaLib.h rename to code/nel/3rdparty/seven_zip/LzmaLib.h diff --git a/code/nel/3rdparty/seven_zip/LzmaUtil.c b/code/nel/3rdparty/seven_zip/LzmaUtil.c new file mode 100644 index 000000000..6bdb2ad6c --- /dev/null +++ b/code/nel/3rdparty/seven_zip/LzmaUtil.c @@ -0,0 +1,258 @@ +/* LzmaUtil.c -- Test application for LZMA compression +2018-07-04 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include +#include +#include + +#include "CpuArch.h" + +#include "Alloc.h" +#include "7zFile.h" +#include "7zVersion.h" +#include "LzmaDec.h" +#include "LzmaEnc.h" + +static const char * const kCantReadMessage = "Can not read input file"; +static const char * const kCantWriteMessage = "Can not write output file"; +static const char * const kCantAllocateMessage = "Can not allocate memory"; +static const char * const kDataErrorMessage = "Data error"; + +static void PrintHelp(char *buffer) +{ + strcat(buffer, + "\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n" + "Usage: lzma inputFile outputFile\n" + " e: encode file\n" + " d: decode file\n"); +} + +static int PrintError(char *buffer, const char *message) +{ + strcat(buffer, "\nError: "); + strcat(buffer, message); + strcat(buffer, "\n"); + return 1; +} + +static int PrintErrorNumber(char *buffer, SRes val) +{ + sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val); + return 1; +} + +static int PrintUserError(char *buffer) +{ + return PrintError(buffer, "Incorrect command"); +} + + +#define IN_BUF_SIZE (1 << 16) +#define OUT_BUF_SIZE (1 << 16) + + +static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream, + UInt64 unpackSize) +{ + int thereIsSize = (unpackSize != (UInt64)(Int64)-1); + Byte inBuf[IN_BUF_SIZE]; + Byte outBuf[OUT_BUF_SIZE]; + size_t inPos = 0, inSize = 0, outPos = 0; + LzmaDec_Init(state); + for (;;) + { + if (inPos == inSize) + { + inSize = IN_BUF_SIZE; + RINOK(inStream->Read(inStream, inBuf, &inSize)); + inPos = 0; + } + { + SRes res; + SizeT inProcessed = inSize - inPos; + SizeT outProcessed = OUT_BUF_SIZE - outPos; + ELzmaFinishMode finishMode = LZMA_FINISH_ANY; + ELzmaStatus status; + if (thereIsSize && outProcessed > unpackSize) + { + outProcessed = (SizeT)unpackSize; + finishMode = LZMA_FINISH_END; + } + + res = LzmaDec_DecodeToBuf(state, outBuf + outPos, &outProcessed, + inBuf + inPos, &inProcessed, finishMode, &status); + inPos += inProcessed; + outPos += outProcessed; + unpackSize -= outProcessed; + + if (outStream) + if (outStream->Write(outStream, outBuf, outPos) != outPos) + return SZ_ERROR_WRITE; + + outPos = 0; + + if (res != SZ_OK || (thereIsSize && unpackSize == 0)) + return res; + + if (inProcessed == 0 && outProcessed == 0) + { + if (thereIsSize || status != LZMA_STATUS_FINISHED_WITH_MARK) + return SZ_ERROR_DATA; + return res; + } + } + } +} + + +static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) +{ + UInt64 unpackSize; + int i; + SRes res = 0; + + CLzmaDec state; + + /* header: 5 bytes of LZMA properties and 8 bytes of uncompressed size */ + unsigned char header[LZMA_PROPS_SIZE + 8]; + + /* Read and parse header */ + + RINOK(SeqInStream_Read(inStream, header, sizeof(header))); + + unpackSize = 0; + for (i = 0; i < 8; i++) + unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); + + LzmaDec_Construct(&state); + RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)); + res = Decode2(&state, outStream, inStream, unpackSize); + LzmaDec_Free(&state, &g_Alloc); + return res; +} + +static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs) +{ + CLzmaEncHandle enc; + SRes res; + CLzmaEncProps props; + + UNUSED_VAR(rs); + + enc = LzmaEnc_Create(&g_Alloc); + if (enc == 0) + return SZ_ERROR_MEM; + + LzmaEncProps_Init(&props); + res = LzmaEnc_SetProps(enc, &props); + + if (res == SZ_OK) + { + Byte header[LZMA_PROPS_SIZE + 8]; + size_t headerSize = LZMA_PROPS_SIZE; + int i; + + res = LzmaEnc_WriteProperties(enc, header, &headerSize); + for (i = 0; i < 8; i++) + header[headerSize++] = (Byte)(fileSize >> (8 * i)); + if (outStream->Write(outStream, header, headerSize) != headerSize) + res = SZ_ERROR_WRITE; + else + { + if (res == SZ_OK) + res = LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc); + } + } + LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc); + return res; +} + + +static int main2(int numArgs, const char *args[], char *rs) +{ + CFileSeqInStream inStream; + CFileOutStream outStream; + char c; + int res; + int encodeMode; + BoolInt useOutFile = False; + + FileSeqInStream_CreateVTable(&inStream); + File_Construct(&inStream.file); + + FileOutStream_CreateVTable(&outStream); + File_Construct(&outStream.file); + + if (numArgs == 1) + { + PrintHelp(rs); + return 0; + } + + if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1) + return PrintUserError(rs); + + c = args[1][0]; + encodeMode = (c == 'e' || c == 'E'); + if (!encodeMode && c != 'd' && c != 'D') + return PrintUserError(rs); + + { + size_t t4 = sizeof(UInt32); + size_t t8 = sizeof(UInt64); + if (t4 != 4 || t8 != 8) + return PrintError(rs, "Incorrect UInt32 or UInt64"); + } + + if (InFile_Open(&inStream.file, args[2]) != 0) + return PrintError(rs, "Can not open input file"); + + if (numArgs > 3) + { + useOutFile = True; + if (OutFile_Open(&outStream.file, args[3]) != 0) + return PrintError(rs, "Can not open output file"); + } + else if (encodeMode) + PrintUserError(rs); + + if (encodeMode) + { + UInt64 fileSize; + File_GetLength(&inStream.file, &fileSize); + res = Encode(&outStream.vt, &inStream.vt, fileSize, rs); + } + else + { + res = Decode(&outStream.vt, useOutFile ? &inStream.vt : NULL); + } + + if (useOutFile) + File_Close(&outStream.file); + File_Close(&inStream.file); + + if (res != SZ_OK) + { + if (res == SZ_ERROR_MEM) + return PrintError(rs, kCantAllocateMessage); + else if (res == SZ_ERROR_DATA) + return PrintError(rs, kDataErrorMessage); + else if (res == SZ_ERROR_WRITE) + return PrintError(rs, kCantWriteMessage); + else if (res == SZ_ERROR_READ) + return PrintError(rs, kCantReadMessage); + return PrintErrorNumber(rs, res); + } + return 0; +} + + +int MY_CDECL main(int numArgs, const char *args[]) +{ + char rs[800] = { 0 }; + int res = main2(numArgs, args, rs); + fputs(rs, stdout); + return res; +} diff --git a/code/ryzom/client/src/seven_zip/Ppmd.h b/code/nel/3rdparty/seven_zip/Ppmd.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Ppmd.h rename to code/nel/3rdparty/seven_zip/Ppmd.h diff --git a/code/ryzom/client/src/seven_zip/Ppmd7.cpp b/code/nel/3rdparty/seven_zip/Ppmd7.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Ppmd7.cpp rename to code/nel/3rdparty/seven_zip/Ppmd7.c diff --git a/code/ryzom/client/src/seven_zip/Ppmd7.h b/code/nel/3rdparty/seven_zip/Ppmd7.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Ppmd7.h rename to code/nel/3rdparty/seven_zip/Ppmd7.h diff --git a/code/ryzom/client/src/seven_zip/Ppmd7Dec.cpp b/code/nel/3rdparty/seven_zip/Ppmd7Dec.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Ppmd7Dec.cpp rename to code/nel/3rdparty/seven_zip/Ppmd7Dec.c diff --git a/code/ryzom/client/src/seven_zip/Ppmd7Enc.cpp b/code/nel/3rdparty/seven_zip/Ppmd7Enc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Ppmd7Enc.cpp rename to code/nel/3rdparty/seven_zip/Ppmd7Enc.c diff --git a/code/nel/3rdparty/seven_zip/Precomp.h b/code/nel/3rdparty/seven_zip/Precomp.h new file mode 100644 index 000000000..e8ff8b40e --- /dev/null +++ b/code/nel/3rdparty/seven_zip/Precomp.h @@ -0,0 +1,10 @@ +/* Precomp.h -- StdAfx +2013-11-12 : Igor Pavlov : Public domain */ + +#ifndef __7Z_PRECOMP_H +#define __7Z_PRECOMP_H + +#include "Compiler.h" +/* #include "7zTypes.h" */ + +#endif diff --git a/code/ryzom/client/src/seven_zip/RotateDefs.h b/code/nel/3rdparty/seven_zip/RotateDefs.h similarity index 100% rename from code/ryzom/client/src/seven_zip/RotateDefs.h rename to code/nel/3rdparty/seven_zip/RotateDefs.h diff --git a/code/ryzom/client/src/seven_zip/Sha256.cpp b/code/nel/3rdparty/seven_zip/Sha256.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Sha256.cpp rename to code/nel/3rdparty/seven_zip/Sha256.c diff --git a/code/ryzom/client/src/seven_zip/Sha256.h b/code/nel/3rdparty/seven_zip/Sha256.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Sha256.h rename to code/nel/3rdparty/seven_zip/Sha256.h diff --git a/code/ryzom/client/src/seven_zip/Sort.cpp b/code/nel/3rdparty/seven_zip/Sort.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Sort.cpp rename to code/nel/3rdparty/seven_zip/Sort.c diff --git a/code/ryzom/client/src/seven_zip/Sort.h b/code/nel/3rdparty/seven_zip/Sort.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Sort.h rename to code/nel/3rdparty/seven_zip/Sort.h diff --git a/code/ryzom/client/src/seven_zip/Xz.cpp b/code/nel/3rdparty/seven_zip/Xz.c similarity index 100% rename from code/ryzom/client/src/seven_zip/Xz.cpp rename to code/nel/3rdparty/seven_zip/Xz.c diff --git a/code/ryzom/client/src/seven_zip/Xz.h b/code/nel/3rdparty/seven_zip/Xz.h similarity index 100% rename from code/ryzom/client/src/seven_zip/Xz.h rename to code/nel/3rdparty/seven_zip/Xz.h diff --git a/code/ryzom/client/src/seven_zip/XzCrc64.cpp b/code/nel/3rdparty/seven_zip/XzCrc64.c similarity index 100% rename from code/ryzom/client/src/seven_zip/XzCrc64.cpp rename to code/nel/3rdparty/seven_zip/XzCrc64.c diff --git a/code/ryzom/client/src/seven_zip/XzCrc64.h b/code/nel/3rdparty/seven_zip/XzCrc64.h similarity index 100% rename from code/ryzom/client/src/seven_zip/XzCrc64.h rename to code/nel/3rdparty/seven_zip/XzCrc64.h diff --git a/code/ryzom/client/src/seven_zip/XzCrc64Opt.cpp b/code/nel/3rdparty/seven_zip/XzCrc64Opt.c similarity index 100% rename from code/ryzom/client/src/seven_zip/XzCrc64Opt.cpp rename to code/nel/3rdparty/seven_zip/XzCrc64Opt.c diff --git a/code/ryzom/client/src/seven_zip/XzDec.cpp b/code/nel/3rdparty/seven_zip/XzDec.c similarity index 100% rename from code/ryzom/client/src/seven_zip/XzDec.cpp rename to code/nel/3rdparty/seven_zip/XzDec.c diff --git a/code/ryzom/client/src/seven_zip/XzEnc.cpp b/code/nel/3rdparty/seven_zip/XzEnc.c similarity index 100% rename from code/ryzom/client/src/seven_zip/XzEnc.cpp rename to code/nel/3rdparty/seven_zip/XzEnc.c diff --git a/code/ryzom/client/src/seven_zip/XzEnc.h b/code/nel/3rdparty/seven_zip/XzEnc.h similarity index 100% rename from code/ryzom/client/src/seven_zip/XzEnc.h rename to code/nel/3rdparty/seven_zip/XzEnc.h diff --git a/code/ryzom/client/src/seven_zip/XzIn.cpp b/code/nel/3rdparty/seven_zip/XzIn.c similarity index 100% rename from code/ryzom/client/src/seven_zip/XzIn.cpp rename to code/nel/3rdparty/seven_zip/XzIn.c diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 3470fcebb..1530e75e3 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -56,6 +56,7 @@ IF(WITH_INSTALL_LIBRARIES) ADD_SUBDIRECTORY(include) ENDIF() +ADD_SUBDIRECTORY(3rdparty) ADD_SUBDIRECTORY(src) IF(WITH_NEL_SAMPLES) diff --git a/code/nel/include/nel/3d/bloom_effect.h b/code/nel/include/nel/3d/bloom_effect.h index 49c959e23..1f49645a4 100644 --- a/code/nel/include/nel/3d/bloom_effect.h +++ b/code/nel/include/nel/3d/bloom_effect.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/computed_string.h b/code/nel/include/nel/3d/computed_string.h index 25d12a3ac..3f27a2879 100644 --- a/code/nel/include/nel/3d/computed_string.h +++ b/code/nel/include/nel/3d/computed_string.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 85140b3da..75472df37 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 62c6fd6db..c3564975f 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -1,6 +1,11 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2010 Robert TIMM (rti) +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index c23d41382..49386487b 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/fxaa.h b/code/nel/include/nel/3d/fxaa.h index f7ccf4866..9f97b81ad 100644 --- a/code/nel/include/nel/3d/fxaa.h +++ b/code/nel/include/nel/3d/fxaa.h @@ -6,24 +6,21 @@ * CFXAA */ -/* - * Copyright (C) 2014 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL3D_FXAA_H #define NL3D_FXAA_H diff --git a/code/nel/include/nel/3d/geometry_program.h b/code/nel/include/nel/3d/geometry_program.h index 48e48e260..f8de082d6 100644 --- a/code/nel/include/nel/3d/geometry_program.h +++ b/code/nel/include/nel/3d/geometry_program.h @@ -2,24 +2,24 @@ * Geometry program definition */ -/* Copyright, 2000, 2001 Nevrax Ltd. - * - * This file is part of NEVRAX NEL. - * NEVRAX NEL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - - * NEVRAX NEL is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with NEVRAX NEL; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - */ +// NeL - MMORPG Framework +// Copyright (C) 2000-2001 Nevrax Ltd. +// +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL_GEOMETRY_PROGRAM_H #define NL_GEOMETRY_PROGRAM_H diff --git a/code/nel/include/nel/3d/gpu_program_params.h b/code/nel/include/nel/3d/gpu_program_params.h index 4615c58d9..337e611ea 100644 --- a/code/nel/include/nel/3d/gpu_program_params.h +++ b/code/nel/include/nel/3d/gpu_program_params.h @@ -6,24 +6,21 @@ * CGPUProgramParams */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ +// NeL - MMORPG Framework +// Copyright (C) 2013 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL3D_GPU_PROGRAM_PARAMS_H #define NL3D_GPU_PROGRAM_PARAMS_H diff --git a/code/nel/include/nel/3d/landscape.h b/code/nel/include/nel/3d/landscape.h index a7383963d..f6e1a5861 100644 --- a/code/nel/include/nel/3d/landscape.h +++ b/code/nel/include/nel/3d/landscape.h @@ -100,8 +100,8 @@ public: public: EBadBind() {} - ~EBadBind() throw () {} - virtual const char *what() const throw(); + virtual ~EBadBind() NL_OVERRIDE {} + virtual const char *what() const throw() NL_OVERRIDE; }; diff --git a/code/nel/include/nel/3d/landscapevb_allocator.h b/code/nel/include/nel/3d/landscapevb_allocator.h index 0e485e990..fbf6f1eb4 100644 --- a/code/nel/include/nel/3d/landscapevb_allocator.h +++ b/code/nel/include/nel/3d/landscapevb_allocator.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/material.h b/code/nel/include/nel/3d/material.h index 7a300da45..9c8865124 100644 --- a/code/nel/include/nel/3d/material.h +++ b/code/nel/include/nel/3d/material.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/meshvp_per_pixel_light.h b/code/nel/include/nel/3d/meshvp_per_pixel_light.h index 4533464a9..9aef9fb0a 100644 --- a/code/nel/include/nel/3d/meshvp_per_pixel_light.h +++ b/code/nel/include/nel/3d/meshvp_per_pixel_light.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/meshvp_wind_tree.h b/code/nel/include/nel/3d/meshvp_wind_tree.h index 790a2f774..e3e8e8bc2 100644 --- a/code/nel/include/nel/3d/meshvp_wind_tree.h +++ b/code/nel/include/nel/3d/meshvp_wind_tree.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/pixel_program.h b/code/nel/include/nel/3d/pixel_program.h index 0787ae9fb..31818f1cd 100644 --- a/code/nel/include/nel/3d/pixel_program.h +++ b/code/nel/include/nel/3d/pixel_program.h @@ -2,24 +2,24 @@ * Pixel program definition */ -/* Copyright, 2000, 2001 Nevrax Ltd. - * - * This file is part of NEVRAX NEL. - * NEVRAX NEL is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - - * NEVRAX NEL is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with NEVRAX NEL; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - */ +// NeL - MMORPG Framework +// Copyright (C) 2000-2001 Nevrax Ltd. +// +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL_PIXEL_PROGRAM_H #define NL_PIXEL_PROGRAM_H diff --git a/code/nel/include/nel/3d/program.h b/code/nel/include/nel/3d/program.h index 77e6baa62..c84a97058 100644 --- a/code/nel/include/nel/3d/program.h +++ b/code/nel/include/nel/3d/program.h @@ -6,24 +6,21 @@ * IProgram */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ +// NeL - MMORPG Framework +// Copyright (C) 2013 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL3D_PROGRAM_H #define NL3D_PROGRAM_H diff --git a/code/nel/include/nel/3d/ps_sound.h b/code/nel/include/nel/3d/ps_sound.h index d1c990770..c716dd2a3 100644 --- a/code/nel/include/nel/3d/ps_sound.h +++ b/code/nel/include/nel/3d/ps_sound.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -21,7 +24,6 @@ #include "nel/misc/string_mapper.h" #include "nel/3d/ps_located.h" #include "nel/3d/ps_attrib.h" -#include "nel/misc/sheet_id.h" @@ -64,13 +66,13 @@ public: virtual void step(TPSProcessPass pass); /// set the name of the sound - void setSoundName(const NLMISC::CSheetId &soundName) + void setSoundName(const NLMISC::TStringId &soundName) { _SoundName = soundName; } /// get the name of the sound - const NLMISC::CSheetId &getSoundName(void) const + const NLMISC::TStringId &getSoundName(void) const { return _SoundName; } @@ -162,7 +164,7 @@ protected: void removeAllSources(); CPSAttrib _Sounds; - NLMISC::CSheetId _SoundName; + NLMISC::TStringId _SoundName; float _Gain; CPSAttribMaker * _GainScheme; float _Pitch; diff --git a/code/nel/include/nel/3d/render_target_manager.h b/code/nel/include/nel/3d/render_target_manager.h index cae8e31b0..ac69b4228 100644 --- a/code/nel/include/nel/3d/render_target_manager.h +++ b/code/nel/include/nel/3d/render_target_manager.h @@ -6,24 +6,22 @@ * CRenderTargetManager */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ + +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL3D_RENDER_TARGET_MANAGER_H #define NL3D_RENDER_TARGET_MANAGER_H diff --git a/code/nel/include/nel/3d/render_trav.h b/code/nel/include/nel/3d/render_trav.h index 41570c2ca..8ea14fabf 100644 --- a/code/nel/include/nel/3d/render_trav.h +++ b/code/nel/include/nel/3d/render_trav.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/scene.h b/code/nel/include/nel/3d/scene.h index 12c18b484..39d9707b7 100644 --- a/code/nel/include/nel/3d/scene.h +++ b/code/nel/include/nel/3d/scene.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/scene_user.h b/code/nel/include/nel/3d/scene_user.h index 639fa33d8..4abadb32e 100644 --- a/code/nel/include/nel/3d/scene_user.h +++ b/code/nel/include/nel/3d/scene_user.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/skeleton_model.h b/code/nel/include/nel/3d/skeleton_model.h index dccafd1f1..85644e646 100644 --- a/code/nel/include/nel/3d/skeleton_model.h +++ b/code/nel/include/nel/3d/skeleton_model.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/stereo_debugger.h b/code/nel/include/nel/3d/stereo_debugger.h index 6c974f93d..2ce751cb3 100644 --- a/code/nel/include/nel/3d/stereo_debugger.h +++ b/code/nel/include/nel/3d/stereo_debugger.h @@ -6,24 +6,22 @@ * CStereoDebugger */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ + +// NeL - MMORPG Framework +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #if !FINAL_VERSION #ifndef NL3D_STEREO_DEBUGGER_H diff --git a/code/nel/include/nel/3d/stereo_display.h b/code/nel/include/nel/3d/stereo_display.h index 3b6fdbb21..3ad941ee7 100644 --- a/code/nel/include/nel/3d/stereo_display.h +++ b/code/nel/include/nel/3d/stereo_display.h @@ -6,24 +6,21 @@ * IStereoDisplay */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ +// NeL - MMORPG Framework +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL3D_STEREO_DISPLAY_H #define NL3D_STEREO_DISPLAY_H diff --git a/code/nel/include/nel/3d/stereo_libvr.h b/code/nel/include/nel/3d/stereo_libvr.h index 76d1966fe..60fce94d9 100644 --- a/code/nel/include/nel/3d/stereo_libvr.h +++ b/code/nel/include/nel/3d/stereo_libvr.h @@ -6,24 +6,21 @@ * CStereoLibVR */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - */ +// NeL - MMORPG Framework +// Copyright (C) 2013 Thibaut GIRKA (ThibG) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . #ifndef NL3D_STEREO_LIBVR_H #define NL3D_STEREO_LIBVR_H diff --git a/code/nel/include/nel/3d/stereo_ovr.h b/code/nel/include/nel/3d/stereo_ovr.h index 750f32027..a9fc1a331 100644 --- a/code/nel/include/nel/3d/stereo_ovr.h +++ b/code/nel/include/nel/3d/stereo_ovr.h @@ -6,40 +6,37 @@ * CStereoOVR */ -/* - * Copyright (C) 2013 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - * - * Linking this library statically or dynamically with other modules - * is making a combined work based on this library. Thus, the terms - * and conditions of the GNU General Public License cover the whole - * combination. - * - * As a special exception, the copyright holders of this library give - * you permission to link this library with the Oculus SDK to produce - * an executable, regardless of the license terms of the Oculus SDK, - * and distribute linked combinations including the two, provided that - * you also meet the terms and conditions of the license of the Oculus - * SDK. You must obey the GNU General Public License in all respects - * for all of the code used other than the Oculus SDK. If you modify - * this file, you may extend this exception to your version of the - * file, but you are not obligated to do so. If you do not wish to do - * so, delete this exception statement from your version. - */ +// NeL - MMORPG Framework +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// Linking this library statically or dynamically with other modules +// is making a combined work based on this library. Thus, the terms +// and conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give +// you permission to link this library with the Oculus SDK to produce +// an executable, regardless of the license terms of the Oculus SDK, +// and distribute linked combinations including the two, provided that +// you also meet the terms and conditions of the license of the Oculus +// SDK. You must obey the GNU General Public License in all respects +// for all of the code used other than the Oculus SDK. If you modify +// this file, you may extend this exception to your version of the +// file, but you are not obligated to do so. If you do not wish to do +// so, delete this exception statement from your version. #ifndef NL3D_STEREO_OVR_H #define NL3D_STEREO_OVR_H diff --git a/code/nel/include/nel/3d/stereo_ovr_04.h b/code/nel/include/nel/3d/stereo_ovr_04.h index 8bda88c88..1cf1b61c7 100644 --- a/code/nel/include/nel/3d/stereo_ovr_04.h +++ b/code/nel/include/nel/3d/stereo_ovr_04.h @@ -6,40 +6,37 @@ * CStereoOVR */ -/* - * Copyright (C) 2014 by authors - * - * This file is part of NL3D. - * NL3D is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * NL3D is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General - * Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with NL3D. If not, see - * . - * - * Linking this library statically or dynamically with other modules - * is making a combined work based on this library. Thus, the terms - * and conditions of the GNU General Public License cover the whole - * combination. - * - * As a special exception, the copyright holders of this library give - * you permission to link this library with the Oculus SDK to produce - * an executable, regardless of the license terms of the Oculus SDK, - * and distribute linked combinations including the two, provided that - * you also meet the terms and conditions of the license of the Oculus - * SDK. You must obey the GNU General Public License in all respects - * for all of the code used other than the Oculus SDK. If you modify - * this file, you may extend this exception to your version of the - * file, but you are not obligated to do so. If you do not wish to do - * so, delete this exception statement from your version. - */ +// NeL - MMORPG Framework +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// Linking this library statically or dynamically with other modules +// is making a combined work based on this library. Thus, the terms +// and conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give +// you permission to link this library with the Oculus SDK to produce +// an executable, regardless of the license terms of the Oculus SDK, +// and distribute linked combinations including the two, provided that +// you also meet the terms and conditions of the license of the Oculus +// SDK. You must obey the GNU General Public License in all respects +// for all of the code used other than the Oculus SDK. If you modify +// this file, you may extend this exception to your version of the +// file, but you are not obligated to do so. If you do not wish to do +// so, delete this exception statement from your version. #ifndef NL3D_STEREO_OVR_04_H #define NL3D_STEREO_OVR_04_H diff --git a/code/nel/include/nel/3d/text_context.h b/code/nel/include/nel/3d/text_context.h index 1f75e1184..1eb256855 100644 --- a/code/nel/include/nel/3d/text_context.h +++ b/code/nel/include/nel/3d/text_context.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/text_context_user.h b/code/nel/include/nel/3d/text_context_user.h index 15e93c3f2..2a167b2e9 100644 --- a/code/nel/include/nel/3d/text_context_user.h +++ b/code/nel/include/nel/3d/text_context_user.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/texture.h b/code/nel/include/nel/3d/texture.h index 5b8e7ef37..f74af29d9 100644 --- a/code/nel/include/nel/3d/texture.h +++ b/code/nel/include/nel/3d/texture.h @@ -106,7 +106,8 @@ public: class ITexture : public CBitmap, public NLMISC::CRefCount, public NLMISC::IStreamable { public: - NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR // for fast alloc + // TODO: FIX: NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR // for fast alloc + // Those enums MUST be the same than in UTexture!! enum TWrapMode { diff --git a/code/nel/include/nel/3d/texture_bump.h b/code/nel/include/nel/3d/texture_bump.h index 1fb6152de..1c1f2a245 100644 --- a/code/nel/include/nel/3d/texture_bump.h +++ b/code/nel/include/nel/3d/texture_bump.h @@ -84,14 +84,6 @@ protected: float *_NormalizationFactor; bool _DisableSharing; bool _ForceNormalize; - // Map that give the normalization factor for each map from its sharename. This avoid to generate several time the maps to get the normalization factor if a bumpmap is shared by severals CTextureBump instances; - struct CNormalizationInfo - { - uint NumRefs; - float NormalizationFactor; - }; - typedef std::map TNameToNI; // sharename to the normalization factor - static TNameToNI _NameToNF; // name to normalization factor private: /// we don't allow for mipmap for bump so we redefine this to prevent the user from doing this on the base class Itexture virtual void setFilterMode(TMagFilter magf, TMinFilter minf); diff --git a/code/nel/include/nel/3d/tile_bank.h b/code/nel/include/nel/3d/tile_bank.h index 7d4eda3a7..c320b50c7 100644 --- a/code/nel/include/nel/3d/tile_bank.h +++ b/code/nel/include/nel/3d/tile_bank.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 0500192ad..f4f78e2cb 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -1,6 +1,11 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2010 Robert TIMM (rti) +// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/u_ps_sound_impl.h b/code/nel/include/nel/3d/u_ps_sound_impl.h index bf45b6387..8a6869d0b 100644 --- a/code/nel/include/nel/3d/u_ps_sound_impl.h +++ b/code/nel/include/nel/3d/u_ps_sound_impl.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -162,7 +165,7 @@ public: /// inherited from IPSSoundServer - UPSSoundInstance *createSound(const NLMISC::CSheetId &soundName, bool spawned = true) + UPSSoundInstance *createSound(const NLMISC::TStringId &soundName, bool spawned = true) { if (!_AudioMixer) return NULL; diff --git a/code/nel/include/nel/3d/u_ps_sound_interface.h b/code/nel/include/nel/3d/u_ps_sound_interface.h index 82002470b..7faea5fc5 100644 --- a/code/nel/include/nel/3d/u_ps_sound_interface.h +++ b/code/nel/include/nel/3d/u_ps_sound_interface.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -19,7 +22,6 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" -#include "nel/misc/sheet_id.h" #include namespace NLMISC @@ -51,7 +53,7 @@ struct UPSSoundServer * \param spawn true if the sound must be spawned e.g it continues after this interface is removed * \param cb useful only for spawned sound, it tells when a spawned sound has been removed */ - virtual UPSSoundInstance *createSound(const NLMISC::CSheetId &soundName, bool spawn = false) = 0; + virtual UPSSoundInstance *createSound(const NLMISC::TStringId &soundName, bool spawn = false) = 0; }; diff --git a/code/nel/include/nel/3d/u_scene.h b/code/nel/include/nel/3d/u_scene.h index c0733c5d2..4bb831bb2 100644 --- a/code/nel/include/nel/3d/u_scene.h +++ b/code/nel/include/nel/3d/u_scene.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/u_text_context.h b/code/nel/include/nel/3d/u_text_context.h index 4c1dfea47..cdde02f82 100644 --- a/code/nel/include/nel/3d/u_text_context.h +++ b/code/nel/include/nel/3d/u_text_context.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/vegetable_manager.h b/code/nel/include/nel/3d/vegetable_manager.h index ee21af3f3..e1a2001a0 100644 --- a/code/nel/include/nel/3d/vegetable_manager.h +++ b/code/nel/include/nel/3d/vegetable_manager.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/vertex_program.h b/code/nel/include/nel/3d/vertex_program.h index 3d77c6104..f493ccb2b 100644 --- a/code/nel/include/nel/3d/vertex_program.h +++ b/code/nel/include/nel/3d/vertex_program.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/vertex_program_parse.h b/code/nel/include/nel/3d/vertex_program_parse.h index 88538da07..2ecb9f86b 100644 --- a/code/nel/include/nel/3d/vertex_program_parse.h +++ b/code/nel/include/nel/3d/vertex_program_parse.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/water_env_map.h b/code/nel/include/nel/3d/water_env_map.h index 2282610d7..0d02f98ca 100644 --- a/code/nel/include/nel/3d/water_env_map.h +++ b/code/nel/include/nel/3d/water_env_map.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/water_shape.h b/code/nel/include/nel/3d/water_shape.h index 633da8611..192423720 100644 --- a/code/nel/include/nel/3d/water_shape.h +++ b/code/nel/include/nel/3d/water_shape.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/3d/zone_lighter.h b/code/nel/include/nel/3d/zone_lighter.h index 4f2910c52..92708a38b 100644 --- a/code/nel/include/nel/3d/zone_lighter.h +++ b/code/nel/include/nel/3d/zone_lighter.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/CMakeLists.txt b/code/nel/include/nel/CMakeLists.txt index 4df9413b5..fda0ddbe9 100644 --- a/code/nel/include/nel/CMakeLists.txt +++ b/code/nel/include/nel/CMakeLists.txt @@ -4,6 +4,10 @@ IF(WITH_3D) SUBDIRS(3d) ENDIF() +IF(WITH_WEB OR WITH_GUI) + ADD_SUBDIRECTORY(web) +ENDIF() + IF(WITH_GUI) ADD_SUBDIRECTORY(gui) ENDIF() diff --git a/code/nel/include/nel/georges/form.h b/code/nel/include/nel/georges/form.h index da5c0ea88..9b21c4c49 100644 --- a/code/nel/include/nel/georges/form.h +++ b/code/nel/include/nel/georges/form.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/georges/form_dfn.h b/code/nel/include/nel/georges/form_dfn.h index 4e9870043..c6ab83a07 100644 --- a/code/nel/include/nel/georges/form_dfn.h +++ b/code/nel/include/nel/georges/form_dfn.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/georges/form_elm.h b/code/nel/include/nel/georges/form_elm.h index 738e6a55a..bf9b3ef62 100644 --- a/code/nel/include/nel/georges/form_elm.h +++ b/code/nel/include/nel/georges/form_elm.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/georges/form_loader.h b/code/nel/include/nel/georges/form_loader.h index c46d79f22..2dc998b11 100644 --- a/code/nel/include/nel/georges/form_loader.h +++ b/code/nel/include/nel/georges/form_loader.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/georges/header.h b/code/nel/include/nel/georges/header.h index 82a094b3d..61351dfe9 100644 --- a/code/nel/include/nel/georges/header.h +++ b/code/nel/include/nel/georges/header.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/georges/type.h b/code/nel/include/nel/georges/type.h index e1bad7934..5d9c6706e 100644 --- a/code/nel/include/nel/georges/type.h +++ b/code/nel/include/nel/georges/type.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/georges/u_form.h b/code/nel/include/nel/georges/u_form.h index d53e415f7..4f77a8b80 100644 --- a/code/nel/include/nel/georges/u_form.h +++ b/code/nel/include/nel/georges/u_form.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/action_handler.h b/code/nel/include/nel/gui/action_handler.h index f0f4c46f8..7288c9529 100644 --- a/code/nel/include/nel/gui/action_handler.h +++ b/code/nel/include/nel/gui/action_handler.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/css_border_renderer.h b/code/nel/include/nel/gui/css_border_renderer.h new file mode 100644 index 000000000..41ea3b7e6 --- /dev/null +++ b/code/nel/include/nel/gui/css_border_renderer.h @@ -0,0 +1,94 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_CSS_BORDER_RENDERER_H +#define NL_CSS_BORDER_RENDERER_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/misc/geom_ext.h" +#include "nel/gui/css_types.h" + +namespace NLGUI +{ + /** + * \brief Border renderer for GUI classes + * \date 2019-09-03 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CSSBorderRenderer + { + private: + // parent element screen coordinates + sint32 _XReal, _YReal; + sint32 _WReal, _HReal; + + NLMISC::CQuadUV _QuadT; + NLMISC::CQuadUV _QuadR; + NLMISC::CQuadUV _QuadB; + NLMISC::CQuadUV _QuadL; + + uint8 _RenderLayer; + bool _ModulateGlobalColor; + + // if true, then updateCoords() is called from draw() + bool _Dirty; + // if true, then at least one border is set + bool _Border; + bool _BorderTop, _BorderRight, _BorderBottom, _BorderLeft; + + public: + uint32 TopWidth, RightWidth, BottomWidth, LeftWidth; + NLMISC::CRGBA TopColor, RightColor, BottomColor, LeftColor; + CSSLineStyle TopStyle, RightStyle, BottomStyle, LeftStyle; + + // alpha value from parent + uint8 CurrentAlpha; + + public: + CSSBorderRenderer(); + + void setRenderLayer(sint layer); + void setModulateGlobalColor(bool m); + + void setRect(sint32 x, sint32 y, sint32 w, sint32 h); + + void setWidth(uint32 top, uint32 right, uint32 bottom, uint32 left); + void setStyle(CSSLineStyle top, CSSLineStyle right, CSSLineStyle bottom, CSSLineStyle left); + void setColor(const NLMISC::CRGBA &top, const NLMISC::CRGBA &right, const NLMISC::CRGBA &bottom, const NLMISC::CRGBA &left); + + void updateCoords(); + void invalidateCoords() { _Dirty = _Border = true; } + void invalidateContent() { _Dirty = _Border = true; }; + + uint32 getTopWidth() const; + uint32 getRightWidth() const; + uint32 getBottomWidth() const; + uint32 getLeftWidth() const; + + uint32 getLeftRightWidth() const; + uint32 getTopBottomWidth() const; + + void draw(); + }; // CSSBorderRenderer + +}//namespace + +#endif // NL_CSS_BORDER_RENDERER_H + + diff --git a/code/nel/include/nel/gui/css_parser.h b/code/nel/include/nel/gui/css_parser.h new file mode 100644 index 000000000..a6dc92022 --- /dev/null +++ b/code/nel/include/nel/gui/css_parser.h @@ -0,0 +1,150 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_CSS_PARSER_H +#define CL_CSS_PARSER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/css_style.h" +#include "nel/gui/css_selector.h" + +namespace NLGUI +{ + /** + * \brief CSS style parsing + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CCssParser { + public: + // parse style declaration, eg "color: red; font-size: 10px;" + static TStyleVec parseDecls(const std::string &styleString); + + // parse css stylesheet + void parseStylesheet(const std::string &cssString, std::vector &rules); + + private: + // stylesheet currently parsed + ucstring _Style; + // keep track of current position in _Style + size_t _Position; + + std::vector _Rules; + + private: + // @media ( .. ) { .. } + void readAtRule(); + + // a#id.class[attr=val] { .. } + void readRule(); + + // move past whitespace + void skipWhitespace(); + + // skip valid IDENT + bool skipIdentifier(); + + // skip over {}, (), or [] block + void skipBlock(); + + // skip over string quoted with ' or " + void skipString(); + + // backslash escape + void escape(); + + // normalize newline chars and remove comments + void preprocess(); + + // parse selectors + combinators + std::vector parse_selector(const ucstring &sel, std::string &pseudoElement) const; + + // parse selector and style + void parseRule(const ucstring &selectorString, const ucstring &styleString); + + inline bool is_eof() const + { + return _Position >= _Style.size(); + } + + inline bool is_whitespace(ucchar ch) const + { + return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n'); + } + + inline bool is_hex(ucchar ch) const + { + return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') || + (ch >= (ucchar)'a' && ch <= (ucchar)'f') || + (ch >= (ucchar)'A' && ch <= (ucchar)'F')); + } + + inline bool maybe_escape() const + { + // escaping newline (\n) only allowed inside strings + return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n'; + } + + inline bool is_quote(ucchar ch) const + { + return ch== (ucchar)'"' || ch == (ucchar)'\''; + } + + inline bool is_block_open(ucchar ch) const + { + return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'('; + } + + inline bool is_block_close(ucchar ch, ucchar open) const + { + return ((open == '{' && ch == (ucchar)'}') || + (open == '[' && ch == (ucchar)']') || + (open == '(' && ch == (ucchar)')')); + } + + inline bool is_comment_open() const + { + if (_Position+1 > _Style.size()) + return false; + + return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*'; + } + + inline bool is_nonascii(ucchar ch) const + { + return ch >= 0x80 /*&& ch <= 255*/; + } + + inline bool is_alpha(ucchar ch) const + { + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); + } + + inline bool is_digit(ucchar ch) const + { + return ch >= '0' && ch <= '9'; + } + + inline bool is_nmchar(ucchar ch) const + { + // checking escape here does not check if next char is '\n' or not + return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/; + } + }; +}//namespace + +#endif // CL_CSS_PARSER_H + diff --git a/code/nel/include/nel/gui/css_selector.h b/code/nel/include/nel/gui/css_selector.h new file mode 100644 index 000000000..ed04ba86d --- /dev/null +++ b/code/nel/include/nel/gui/css_selector.h @@ -0,0 +1,112 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_CSS_SELECTOR_H +#define CL_CSS_SELECTOR_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + class CHtmlElement; + + /** + * \brief CSS selector + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CCssSelector + { + public: + enum ECombinator { + NONE = 0, + GENERAL_CHILD, + ADJACENT_SIBLING, + GENERAL_SIBLING, + CHILD_OF + }; + + struct SAttribute { + std::string key; + std::string value; + char op; // =, ~, |, ^, $, * + bool caseSensitive; + SAttribute(const std::string &k, const std::string &v, char o, bool cs) + :key(k),value(v),op(o), caseSensitive(cs) + {} + }; + + std::string Element; + std::string Id; + std::vector Class; + std::vector Attr; + std::vector PseudoClass; + + // css combinator or \0 missing (first element) + char Combinator; + + public: + // TODO: rewrite for ECombinator enum + CCssSelector(std::string elm="", std::string id="", std::string cls="", char comb = '\0'); + + // helper for sorting + uint32 specificity() const; + + // set classes used, eg 'class1 class2' + void setClass(const std::string &cls); + + // add attribute to selector + // ' ' op means 'key exists, ignore value' + // cs case-sensitive true|false + void addAttribute(const std::string &key, const std::string &val = "", char op = ' ', bool cs = true); + + // add pseudo class to selector, eg 'first-child' + void addPseudoClass(const std::string &key); + + // true if no rules have been defined + bool empty() const + { + return Element.empty() && Id.empty() && Class.empty() && Attr.empty() && PseudoClass.empty(); + } + + // Test current selector to html DOM element + // NOTE: Does not check combinator + bool match(const CHtmlElement &elm) const; + + // debug + std::string toString() const; + + private: + bool matchClass(const CHtmlElement &elm) const; + bool matchAttributes(const CHtmlElement &elm) const; + bool matchPseudoClass(const CHtmlElement &elm) const; + + // match An+B rule to child index (1 based) + bool matchNth(sint childNr, sint a, sint b) const; + + // parse nth-child string to 'a' and 'b' components + // :nth-child(odd) + // :nth-child(even) + // :nth-child(An+B) + // :nth-child(-An+b) + void parseNth(const std::string &pseudo, sint &a, sint &b) const; + + }; + +}//namespace + +#endif // CL_CSS_SELECTOR_H + diff --git a/code/nel/include/nel/gui/css_style.h b/code/nel/include/nel/gui/css_style.h new file mode 100644 index 000000000..5521818a4 --- /dev/null +++ b/code/nel/include/nel/gui/css_style.h @@ -0,0 +1,268 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_CSS_STYLE_H +#define CL_CSS_STYLE_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/gui/css_selector.h" +#include "nel/gui/css_types.h" + +namespace NLGUI +{ + class CHtmlElement; + + typedef std::map TStyle; + typedef std::pair TStylePair; + typedef std::vector TStyleVec; + + /** + * \brief CSS style rules + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CStyleParams + { + public: + struct STextShadow + { + public: + STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black) + : Enabled(enabled), Outline(outline), X(x), Y(y), Color(color) + { } + + bool Enabled; + bool Outline; + sint32 X; + sint32 Y; + NLMISC::CRGBA Color; + }; + public: + CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow() + { + FontSize=10; + FontWeight=400; + FontOblique=false; + Underlined=false; + StrikeThrough=false; + GlobalColor=false; + DisplayBlock=false; + Width=-1; + Height=-1; + MaxWidth=-1; + MaxHeight=-1; + // border style + BorderTopWidth = BorderRightWidth = BorderBottomWidth = BorderLeftWidth = CSS_LINE_WIDTH_MEDIUM; + BorderTopStyle = BorderRightStyle = BorderBottomStyle = BorderLeftStyle = CSS_LINE_STYLE_NONE; + BorderTopColor = BorderRightColor = BorderBottomColor = BorderLeftColor = NLMISC::CRGBA::Transparent; + // background + BackgroundColor=NLMISC::CRGBA::Black; + BackgroundColorOver=NLMISC::CRGBA::Black; + PaddingTop = PaddingRight = PaddingBottom = PaddingLeft = 0; + } + + bool hasStyle(const std::string &key) const + { + return StyleRules.find(key) != StyleRules.end(); + } + + std::string getStyle(const std::string &key) const + { + TStyle::const_iterator it = StyleRules.find(key); + return (it != StyleRules.end() ? it->second : ""); + } + + public: + uint FontSize; + uint FontWeight; + bool FontOblique; + std::string FontFamily; + NLMISC::CRGBA TextColor; + STextShadow TextShadow; + bool GlobalColor; + bool Underlined; + bool StrikeThrough; + bool DisplayBlock; + sint32 Width; + sint32 Height; + sint32 MaxWidth; + sint32 MaxHeight; + uint32 BorderTopWidth, BorderRightWidth, BorderBottomWidth, BorderLeftWidth; + CSSLineStyle BorderTopStyle, BorderRightStyle, BorderBottomStyle, BorderLeftStyle; + NLMISC::CRGBA BorderTopColor, BorderRightColor, BorderBottomColor, BorderLeftColor; + NLMISC::CRGBA BackgroundColor; + NLMISC::CRGBA BackgroundColorOver; + uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft; + + std::string WhiteSpace; + std::string TextAlign; + std::string VerticalAlign; + + TStyle StyleRules; + }; + + class CCssStyle { + public: + + struct SStyleRule { + std::vector Selector; + TStyleVec Properties; + + // pseudo element like ':before' + std::string PseudoElement; + + // returns selector specificity + uint specificity() const; + }; + + // 'browser' style, overwriten with '' + CStyleParams Root; + + // current element style + CStyleParams Current; + + // known style rules sorted by specificity + std::vector _StyleRules; + + private: + std::vector _StyleStack; + + // test if str is one of "thin/medium/thick" and return its pixel value + bool scanCssLength(const std::string& str, uint32 &px) const; + + // split css properties string, ie '1px solid rgb(100, 100, 100)' split by ' ' returns 3 parts. + void splitParams(const std::string &str, char sep, std::vector &result) const; + + // read style attribute + void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams ¤t) const; + void getStyleParams(const TStyle &styleRules, CStyleParams &style, const CStyleParams ¤t) const; + + // extract from styleRules into style.StyleRules (expand shorthand, normalize, calculate current font-size) + void normalize(const TStyle &styleRules, CStyleParams &style, const CStyleParams ¤t) const; + + // apply style.StyleRyles + void apply(CStyleParams &style, const CStyleParams ¤t) const; + + // merge src into dest by overwriting key in dest + void merge(TStyle &dst, const TStyleVec &src) const; + + // match selector to dom path + bool match(const std::vector &selector, const CHtmlElement &elm) const; + + // get shorthang 'top right bottom left' index values based size, ie 'padding' syntax + bool getShorthandIndices(const uint32 size, uint8 &t, uint8 &r, uint8 &b, uint8 &l) const; + + // break 'border' into 'border-top-color', 'border-top-style', etc rules + bool tryBorderWidthShorthand(const std::string &prop, const std::string &value, TStyle &style) const; + bool tryBorderStyleShorthand(const std::string &prop, const std::string &value, TStyle &style) const; + bool tryBorderColorShorthand(const std::string &prop, const std::string &value, TStyle &style) const; + void expandBorderShorthand(const std::string &prop, const std::string &value, TStyle &style) const; + + // parse 'background' into 'background-color', 'background-image', etc + void expandBackgroundShorthand(const std::string &value, TStyle &style) const; + + // parse 'padding' into 'padding-top', 'padding-left', etc + void expandPaddingShorthand(const std::string &value, TStyle &style) const; + + // expand shorthand rule, ie "border", into longhand names, ie "border-top-width" + // if shorthand is present in style, then its removed + void expandShorthand(const std::string &prop, const std::string &value, TStyle &style) const; + + // parse string value into corresponding value + void applyBorderWidth(const std::string &value, uint32 *dest, const uint32 currentWidth, const uint32 fontSize) const; + void applyBorderColor(const std::string &value, NLMISC::CRGBA *dest, const NLMISC::CRGBA ¤tColor, const NLMISC::CRGBA &textColor) const; + void applyLineStyle(const std::string &value, CSSLineStyle *dest, const CSSLineStyle ¤tStyle) const; + void applyPaddingWidth(const std::string &value, uint32 *dest, const uint32 currentPadding, uint32 fontSize) const; + + public: + void reset(); + + // parse tag or css file content + void parseStylesheet(const std::string &styleString); + + // set element style from matching css rules + void getStyleFor(CHtmlElement &elm) const; + + inline uint getFontSizeSmaller() const + { + if (Current.FontSize < 5) + return 3; + return Current.FontSize-2; + } + + inline void pushStyle() + { + _StyleStack.push_back(Current); + + Current.GlobalColor = false; + Current.DisplayBlock = false; + Current.Width=-1; + Current.Height=-1; + Current.MaxWidth=-1; + Current.MaxHeight=-1; + + Current.BorderTopWidth = Current.BorderRightWidth = Current.BorderBottomWidth = Current.BorderLeftWidth = CSS_LINE_WIDTH_MEDIUM; + Current.BorderTopStyle = Current.BorderRightStyle = Current.BorderBottomStyle = Current.BorderLeftStyle = CSS_LINE_STYLE_NONE; + Current.BorderTopColor = Current.BorderRightColor = Current.BorderBottomColor = Current.BorderLeftColor = Current.TextColor; + Current.PaddingTop = Current.PaddingRight = Current.PaddingBottom = Current.PaddingLeft = 0; + + Current.StyleRules.clear(); + } + + inline void popStyle() + { + if (_StyleStack.empty()) + { + Current = Root; + } + else + { + Current = _StyleStack.back(); + _StyleStack.pop_back(); + } + } + + // apply style to this.Root + void applyRootStyle(const std::string &styleString); + void applyRootStyle(const TStyle &styleRules); + + // apply style to this.Current + void applyStyle(const std::string &styleString); + void applyStyle(const TStyle &styleRules); + + void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0) const; + + // check if current style property matches value + bool checkStyle(const std::string &key, const std::string &val) const + { + return Current.hasStyle(key) && Current.getStyle(key) == val; + } + + bool hasStyle(const std::string &key) const + { + return Current.hasStyle(key); + } + + std::string getStyle(const std::string &key) const + { + return Current.getStyle(key); + } + }; +}//namespace + +#endif // CL_CSS_STYLE_H + diff --git a/code/ryzom/server/src/input_output_service/news_manager.h b/code/nel/include/nel/gui/css_types.h similarity index 56% rename from code/ryzom/server/src/input_output_service/news_manager.h rename to code/nel/include/nel/gui/css_types.h index dee34e5be..9dd41de36 100644 --- a/code/ryzom/server/src/input_output_service/news_manager.h +++ b/code/nel/include/nel/gui/css_types.h @@ -14,47 +14,36 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#ifndef CL_CSS_TYPES_H +#define CL_CSS_TYPES_H - -#ifndef NEWS_MANAGER_H -#define NEWS_MANAGER_H - - -// misc #include "nel/misc/types_nl.h" -#include "nel/misc/bit_mem_stream.h" - -// game share -#include "game_share/ryzom_entity_id.h" -//#include "game_share/chat_static_database.h" -//#include "game_share/chat_dynamic_database.h" -#include "game_share/news_types.h" - -// std -#include -#include - - -/** - * CNewsManager - * \author Vianney Lecroart - * \author Nevrax France - * \date 2002 - */ -class CNewsManager -{ -public : +namespace NLGUI +{ /** - * Init the manager. + * \brief CSS types used in GUI classes + * \date 2019-09-03 10:50 GMT + * \author Meelis Mägi (Nimetu) */ - static void init (); + // ie. border-style + enum CSSLineStyle { + CSS_LINE_STYLE_NONE = 0, + CSS_LINE_STYLE_HIDDEN, + CSS_LINE_STYLE_SOLID, + CSS_LINE_STYLE_INSET, + CSS_LINE_STYLE_OUTSET + }; + + // ie, border-width (px) + enum CSSLineWidth { + CSS_LINE_WIDTH_THIN = 1, + CSS_LINE_WIDTH_MEDIUM = 3, + CSS_LINE_WIDTH_THICK = 5 + }; - /// return a news of a given type - static void getNews (NEWSTYPE::TNewsType type, NLMISC::CBitMemStream &bms); -}; +}//namespace +#endif // CL_CSS_TYPES_H -#endif // NEWS_MANAGER_H -/* End of news_manager.h */ diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h index 35148b5b0..a8bdef85f 100644 --- a/code/nel/include/nel/gui/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_base_button.h b/code/nel/include/nel/gui/ctrl_base_button.h index d4699305f..3698d9538 100644 --- a/code/nel/include/nel/gui/ctrl_base_button.h +++ b/code/nel/include/nel/gui/ctrl_base_button.h @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -124,9 +127,11 @@ namespace NLGUI // Event part void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); } void setActionOnLeftClickParams(const std::string ¶ms) { _AHOnLeftClickStringParams = params; } + void setActionOnOver (const std::string &actionHandlerName) { _AHOnOver = CAHManager::getInstance()->getAH(actionHandlerName, _AHOverParams); } void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); } void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); } void setParamsOnLeftClick (const std::string ¶msHandlerName) { _AHLeftClickParams = paramsHandlerName; } + void setParamsOnOver (const std::string ¶msHandlerName) { _AHOverParams = paramsHandlerName; } void setParamsOnRightClick (const std::string ¶msHandlerName) { _AHRightClickParams = paramsHandlerName; } void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; } @@ -141,14 +146,16 @@ namespace NLGUI IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; } IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; } IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; } - std::string _getParamsOnOver() const{ return _AHOverParams.toString(); } + std::string _getParamsOnOver() const{ return _AHOverParams.toString(); } std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); } + std::string _getParamsOnRightClick () const { return _AHRightClickParams.toString(); } const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; } const std::string &getParamsOnRightClick () const { return _AHRightClickParams; } const std::string &getParamsOnClockTick () const { return _AHClockTickParams; } // run action on left click void runLeftClickAction(); + void runRightClickAction(); // Context menu accessor/ One for each button void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; } @@ -161,6 +168,7 @@ namespace NLGUI int luaRunLeftClickAction(CLuaState &ls); + int luaRunRightClickAction(CLuaState &ls); REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase) REFLECT_BOOL("pushed", getPushed, setPushed); REFLECT_STRING("col_normal", getColorAsString, setColorAsString); @@ -174,6 +182,11 @@ namespace NLGUI REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick); REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick); REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction); + REFLECT_STRING("onclick_r", _getActionOnRightClick, setActionOnRightClick); + REFLECT_STRING("params_r", _getParamsOnRightClick, setParamsOnRightClick); + REFLECT_LUA_METHOD("runRightClickAction", luaRunRightClickAction); + REFLECT_STRING("onover", _getActionOnOver, setActionOnOver); + REFLECT_STRING("params_over", _getParamsOnOver, setParamsOnOver); REFLECT_EXPORT_END protected: diff --git a/code/nel/include/nel/gui/ctrl_button.h b/code/nel/include/nel/gui/ctrl_button.h index 1910ea72a..20ad9e35b 100644 --- a/code/nel/include/nel/gui/ctrl_button.h +++ b/code/nel/include/nel/gui/ctrl_button.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_col_pick.h b/code/nel/include/nel/gui/ctrl_col_pick.h index dd779e837..2a3e19288 100644 --- a/code/nel/include/nel/gui/ctrl_col_pick.h +++ b/code/nel/include/nel/gui/ctrl_col_pick.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h index 22ace71e0..c54c664bf 100644 --- a/code/nel/include/nel/gui/ctrl_draggable.h +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_polygon.h b/code/nel/include/nel/gui/ctrl_polygon.h index cef57dd3c..2d14d1151 100644 --- a/code/nel/include/nel/gui/ctrl_polygon.h +++ b/code/nel/include/nel/gui/ctrl_polygon.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_quad.h b/code/nel/include/nel/gui/ctrl_quad.h index 08c89675e..29948cb94 100644 --- a/code/nel/include/nel/gui/ctrl_quad.h +++ b/code/nel/include/nel/gui/ctrl_quad.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_scroll.h b/code/nel/include/nel/gui/ctrl_scroll.h index a22da2cbd..76827dd29 100644 --- a/code/nel/include/nel/gui/ctrl_scroll.h +++ b/code/nel/include/nel/gui/ctrl_scroll.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_scroll_base.h b/code/nel/include/nel/gui/ctrl_scroll_base.h index 38cfd9c09..7f4aaad7b 100644 --- a/code/nel/include/nel/gui/ctrl_scroll_base.h +++ b/code/nel/include/nel/gui/ctrl_scroll_base.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_sheet_selection.h b/code/nel/include/nel/gui/ctrl_sheet_selection.h index 36d1c8336..3b0b32d4c 100644 --- a/code/nel/include/nel/gui/ctrl_sheet_selection.h +++ b/code/nel/include/nel/gui/ctrl_sheet_selection.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index e88ec81e1..25fc9eeac 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/ctrl_tooltip.h b/code/nel/include/nel/gui/ctrl_tooltip.h index a96bbad40..fe350c6c5 100644 --- a/code/nel/include/nel/gui/ctrl_tooltip.h +++ b/code/nel/include/nel/gui/ctrl_tooltip.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/db_manager.h b/code/nel/include/nel/gui/db_manager.h index d5036204d..cff3c0f88 100644 --- a/code/nel/include/nel/gui/db_manager.h +++ b/code/nel/include/nel/gui/db_manager.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbgroup_combo_box.h b/code/nel/include/nel/gui/dbgroup_combo_box.h index 723afbdc0..6f42572bb 100644 --- a/code/nel/include/nel/gui/dbgroup_combo_box.h +++ b/code/nel/include/nel/gui/dbgroup_combo_box.h @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2015 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbgroup_select_number.h b/code/nel/include/nel/gui/dbgroup_select_number.h index a5ef692ff..995747ab8 100644 --- a/code/nel/include/nel/gui/dbgroup_select_number.h +++ b/code/nel/include/nel/gui/dbgroup_select_number.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbview_bar.h b/code/nel/include/nel/gui/dbview_bar.h index d4a3de340..f33959191 100644 --- a/code/nel/include/nel/gui/dbview_bar.h +++ b/code/nel/include/nel/gui/dbview_bar.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbview_bar3.h b/code/nel/include/nel/gui/dbview_bar3.h index 785cb165b..93d621f72 100644 --- a/code/nel/include/nel/gui/dbview_bar3.h +++ b/code/nel/include/nel/gui/dbview_bar3.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbview_digit.h b/code/nel/include/nel/gui/dbview_digit.h index 33446b2de..2c832b1e8 100644 --- a/code/nel/include/nel/gui/dbview_digit.h +++ b/code/nel/include/nel/gui/dbview_digit.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbview_number.h b/code/nel/include/nel/gui/dbview_number.h index bfa963fb6..1082ffd31 100644 --- a/code/nel/include/nel/gui/dbview_number.h +++ b/code/nel/include/nel/gui/dbview_number.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/dbview_quantity.h b/code/nel/include/nel/gui/dbview_quantity.h index 67c4e57ba..16a11f5a0 100644 --- a/code/nel/include/nel/gui/dbview_quantity.h +++ b/code/nel/include/nel/gui/dbview_quantity.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/editor_selection_watcher.h b/code/nel/include/nel/gui/editor_selection_watcher.h index 7e262bdf1..f928035e7 100644 --- a/code/nel/include/nel/gui/editor_selection_watcher.h +++ b/code/nel/include/nel/gui/editor_selection_watcher.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/event_descriptor.h b/code/nel/include/nel/gui/event_descriptor.h index d44448027..95bdad212 100644 --- a/code/nel/include/nel/gui/event_descriptor.h +++ b/code/nel/include/nel/gui/event_descriptor.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -60,7 +63,7 @@ public: keystring, // a string has been sent. The string is a ucstring unknown, // uninitialized event }; - CEventDescriptorKey() : _KeyEvent(unknown) + CEventDescriptorKey() : _KeyEvent(unknown), _CtrlState(false), _ShiftState(false), _AltState(false), _Char(0) { _EventType = key; } @@ -102,6 +105,31 @@ public: { return _AltState; } + + // return true if key was pressed or held down at a time of this event + bool isShiftDown() + { + return (_KeyEvent == CEventDescriptorKey::keydown && (_Key == NLMISC::KeySHIFT || _ShiftState)) + || (_KeyEvent == CEventDescriptorKey::keyup && (_Key != NLMISC::KeySHIFT && _ShiftState)) + || (_KeyEvent == CEventDescriptorKey::keychar && _ShiftState); + } + + // return true if key was pressed or held down at a time of this event + bool isCtrlDown() + { + return (_KeyEvent == CEventDescriptorKey::keydown && (_Key == NLMISC::KeyCONTROL || _CtrlState)) + || (_KeyEvent == CEventDescriptorKey::keyup && (_Key != NLMISC::KeyCONTROL && _CtrlState)) + || (_KeyEvent == CEventDescriptorKey::keychar && _CtrlState); + } + + // return true if key was pressed or held down at a time of this event + bool isAltDown() + { + return (_KeyEvent == CEventDescriptorKey::keydown && (_Key == NLMISC::KeyMENU || _AltState)) + || (_KeyEvent == CEventDescriptorKey::keyup && (_Key != NLMISC::KeyMENU && _AltState)) + || (_KeyEvent == CEventDescriptorKey::keychar && _AltState); + } + // init from a CEventKey obj void init(const NLMISC::CEventKey &ev); diff --git a/code/nel/include/nel/gui/event_listener.h b/code/nel/include/nel/gui/event_listener.h index 06a2d0776..f7c44acef 100644 --- a/code/nel/include/nel/gui/event_listener.h +++ b/code/nel/include/nel/gui/event_listener.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_container.h b/code/nel/include/nel/gui/group_container.h index 452674aa1..742dfcfb2 100644 --- a/code/nel/include/nel/gui/group_container.h +++ b/code/nel/include/nel/gui/group_container.h @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2018 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -274,10 +277,13 @@ namespace NLGUI // Lua exports int luaBlink(CLuaState &ls); int luaSetHeaderColor(CLuaState &ls); + int luaSetModalParentList(CLuaState &ls); REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase) REFLECT_LUA_METHOD("blink", luaBlink); REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor); + REFLECT_LUA_METHOD("setModalParentList", luaSetModalParentList); + REFLECT_STRING("title", getTitle, setTitle); REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index 6aa7425b7..ab65b005b 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h index 14d9d55a5..096f3daa0 100644 --- a/code/nel/include/nel/gui/group_editbox.h +++ b/code/nel/include/nel/gui/group_editbox.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_editbox_base.h b/code/nel/include/nel/gui/group_editbox_base.h index 3aa6a555f..bd85a1ba1 100644 --- a/code/nel/include/nel/gui/group_editbox_base.h +++ b/code/nel/include/nel/gui/group_editbox_base.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_editbox_decor.h b/code/nel/include/nel/gui/group_editbox_decor.h index 975177612..13d8a00a3 100644 --- a/code/nel/include/nel/gui/group_editbox_decor.h +++ b/code/nel/include/nel/gui/group_editbox_decor.h @@ -1,5 +1,7 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2014 Laszlo Kis-Adam +// Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// +// This source file has been modified by the following contributors: // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify diff --git a/code/nel/include/nel/gui/group_frame.h b/code/nel/include/nel/gui/group_frame.h index 3d350b4d5..8c3cf2888 100644 --- a/code/nel/include/nel/gui/group_frame.h +++ b/code/nel/include/nel/gui/group_frame.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_header.h b/code/nel/include/nel/gui/group_header.h index ab6c94c35..8c1b0e56d 100644 --- a/code/nel/include/nel/gui/group_header.h +++ b/code/nel/include/nel/gui/group_header.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 55daa3c52..590c43a89 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -1,5 +1,8 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -23,13 +26,12 @@ #include "nel/gui/group_tree.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/group_table.h" -#include "nel/gui/libwww_types.h" +#include "nel/gui/html_element.h" +#include "nel/gui/css_style.h" // forward declaration typedef void CURLM; -typedef std::map TStyle; - namespace NLGUI { class CCtrlButton; @@ -69,69 +71,17 @@ namespace NLGUI /// Maximum concurrent MultiCurl connections per CGroupHTML instance sint32 curlMaxConnections; - SWebOptions(): curlMaxConnections(2) + SWebOptions(): curlMaxConnections(5) { } }; static SWebOptions options; - // text-shadow - struct STextShadow - { - public: - STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black) - : Enabled(enabled), Outline(outline), X(x), Y(y), Color(color) - { } - - bool Enabled; - bool Outline; - sint32 X; - sint32 Y; - NLMISC::CRGBA Color; - }; - - class CStyleParams - { - public: - CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow() - { - FontSize=10; - FontWeight=400; - FontOblique=false; - Underlined=false; - StrikeThrough=false; - GlobalColor=false; - Width=-1; - Height=-1; - MaxWidth=-1; - MaxHeight=-1; - BorderWidth=1; - BackgroundColor=NLMISC::CRGBA::Black; - BackgroundColorOver=NLMISC::CRGBA::Black; - } - uint FontSize; - uint FontWeight; - bool FontOblique; - std::string FontFamily; - NLMISC::CRGBA TextColor; - STextShadow TextShadow; - bool GlobalColor; - bool Underlined; - bool StrikeThrough; - sint32 Width; - sint32 Height; - sint32 MaxWidth; - sint32 MaxHeight; - sint32 BorderWidth; - NLMISC::CRGBA BackgroundColor; - NLMISC::CRGBA BackgroundColorOver; - }; - // ImageDownload system - enum TDataType {ImgType= 0, BnpType}; + enum TDataType {ImgType= 0, BnpType, StylesheetType}; enum TImageType {NormalImage=0, OverImage}; - + // Constructor CGroupHTML(const TCtorParam ¶m); ~CGroupHTML(); @@ -150,25 +100,23 @@ namespace NLGUI // Browse virtual void browse (const char *url); + // load css from local file and insert into active stylesheet collection + void parseStylesheetFile(const std::string &fname); + // parse html string using libxml2 parser - virtual bool parseHtml(std::string htmlString); + bool parseHtml(const std::string &htmlString); // Refresh void refresh(); // submit form - void submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y); + void submitForm(uint button, sint32 x, sint32 y); // Browse error void browseError (const char *msg); - // stop browse - void stopBrowse (); - bool isBrowsing(); - void clean() { stopBrowse(); updateRefreshButton(); removeContent(); } - // Update coords void updateCoords(); @@ -177,9 +125,11 @@ namespace NLGUI // End of the paragraph void endParagraph(); - + // add image download (used by view_bitmap.cpp to load web images) - void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); + void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage, const std::string &placeholder = "web_del.tga"); + // remove image from download list if present + void removeImageDownload(CViewBase *img); std::string localImageName(const std::string &url); // Timeout @@ -264,6 +214,8 @@ namespace NLGUI // Browser home std::string Home; + // Get Home URL + virtual std::string home() const; // Undo browse: Browse the precedent url browsed. no op if none void browseUndo (); @@ -278,6 +230,10 @@ namespace NLGUI std::string getURL() const { return _URL; } void setURL(const std::string &url); + std::string getHTML() const { return _DocumentHtml; } + void setHTML(const std::string &html); + + void setHome(const std::string &home); int luaClearRefresh(CLuaState &ls); int luaClearUndoRedo(CLuaState &ls); @@ -287,11 +243,10 @@ namespace NLGUI int luaInsertText(CLuaState &ls); int luaAddString(CLuaState &ls); int luaAddImage(CLuaState &ls); - int luaBeginElement(CLuaState &ls); - int luaEndElement(CLuaState &ls); int luaShowDiv(CLuaState &ls); int luaParseHtml(CLuaState &ls); int luaRenderHtml(CLuaState &ls); + int luaSetBackground(CLuaState &ls); REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) REFLECT_LUA_METHOD("browse", luaBrowse) @@ -302,12 +257,13 @@ namespace NLGUI REFLECT_LUA_METHOD("insertText", luaInsertText) REFLECT_LUA_METHOD("addString", luaAddString) REFLECT_LUA_METHOD("addImage", luaAddImage) - REFLECT_LUA_METHOD("beginElement", luaBeginElement) - REFLECT_LUA_METHOD("endElement", luaEndElement) REFLECT_LUA_METHOD("showDiv", luaShowDiv) REFLECT_LUA_METHOD("parseHtml", luaParseHtml) REFLECT_LUA_METHOD("renderHtml", luaRenderHtml) + REFLECT_LUA_METHOD("setBackground", luaSetBackground) REFLECT_STRING("url", getURL, setURL) + REFLECT_STRING("html", getHTML, setHTML) + REFLECT_STRING("home", home, setHome) REFLECT_FLOAT("timeout", getTimeout, setTimeout) REFLECT_STRING("title", getTitle, setTitle) REFLECT_EXPORT_END @@ -316,26 +272,20 @@ namespace NLGUI // \name callback from libwww - // Begin of the parsing of a HTML document + // Begin of the rendering of a HTML document virtual void beginBuild (); - // End of the parsing of a HTML document + // End of the rendering of a HTML document virtual void endBuild (); // A new text block has been parsed virtual void addText (const char * buf, int len); // A new begin HTML element has been parsed ( for exemple) - virtual void beginElement (uint element_number, const std::vector &present, const std::vector &value); + virtual void beginElement(CHtmlElement &elm); // A new end HTML element has been parsed ( for exemple) - virtual void endElement (uint element_number); - - // A new begin unparsed element has been found - virtual void beginUnparsedElement(const char *buffer, int length); - - // A new end unparsed element has been found - virtual void endUnparsedElement(const char *buffer, int length); + virtual void endElement(CHtmlElement &elm); // Add GET params to the url virtual void addHTTPGetParams (std::string &url, bool trustedDomain); @@ -343,15 +293,8 @@ namespace NLGUI // Add POST params to the libwww list virtual void addHTTPPostParams (SFormFields &formfields, bool trustedDomain); - // the current request is terminated - virtual void requestTerminated(); - - // libxml2 html parser functions - void htmlElement(xmlNode *node, int element_number); - void htmlWalkDOM(xmlNode *a_node); - - // Get Home URL - virtual std::string home(); + // parse dom node and all child nodes recursively + void renderDOM(CHtmlElement &elm); // Clear style stack and restore default style void resetCssStyle(); @@ -383,7 +326,7 @@ namespace NLGUI void addString(const ucstring &str); // Add an image in the current paragraph - void addImage(const std::string &id, const char *image, bool reloadImg=false, const CStyleParams &style = CStyleParams()); + void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams()); // Add a text area in the current paragraph CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength); @@ -394,7 +337,7 @@ namespace NLGUI // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, - const std::string &overBitmap, const char *actionHandler, const char *actionHandlerParams, const char *tooltip, + const std::string &overBitmap, const char *actionHandler, const char *actionHandlerParams, const std::string &tooltip, const CStyleParams &style = CStyleParams()); // Set the background color @@ -417,11 +360,23 @@ namespace NLGUI // Delete page content and prepare next page void removeContent (); + // Counter to number html elements without id attribute + uint32 getNextAutoIdSeq() { return _AutoIdSeq++; } + uint32 _AutoIdSeq; + // Current URL for relative links in page std::string _URL; // Current URL std::string _DocumentUrl; std::string _DocumentDomain; + std::string _DocumentHtml; // not updated only set by first render + // If true, then render _DocumentHtml on next update (replaces content) + bool _RenderNextTime; + // true if renderer is waiting for css files to finish downloading (link rel=stylesheet) + bool _WaitingForStylesheet; + // list of css file urls that are queued up for download + std::vector _StylesheetQueue; + // Valid base href was found bool _IgnoreBaseUrlTag; // Fragment from loading url @@ -446,6 +401,7 @@ namespace NLGUI bool _BrowseNextTime; bool _PostNextTime; uint _PostFormId; + std::string _PostFormAction; std::string _PostFormSubmitType; std::string _PostFormSubmitButton; std::string _PostFormSubmitValue; @@ -454,7 +410,6 @@ namespace NLGUI // Browsing.. bool _Browsing; - bool _Connecting; double _TimeoutValue; // the timeout in seconds double _ConnectingTimeout; sint _RedirectsRemaining; @@ -469,6 +424,7 @@ namespace NLGUI // True when the element has been encountered bool _ParsingLua; bool _IgnoreText; + bool _IgnoreChildElements; // the script to execute std::string _LuaScript; bool _LuaHrefHack; @@ -527,6 +483,64 @@ namespace NLGUI }; std::vector _UL; + class HTMLMeterElement { + public: + enum EValueRegion { + VALUE_OPTIMUM = 0, + VALUE_SUB_OPTIMAL, + VALUE_EVEN_LESS_GOOD + }; + public: + HTMLMeterElement() + : value(0.f), min(0.f), max(1.f), low(0.f), high(1.f), optimum(0.5f) + {} + + // read attributes from html element + void readValues(const CHtmlElement &elm); + + // return value ratio to min-max + float getValueRatio() const; + + // return optimum region based current value + EValueRegion getValueRegion() const; + + // return meter bar color + NLMISC::CRGBA getBarColor(const CHtmlElement &elm, CCssStyle &style) const; + + // return meter value bar color based value and optimum range + NLMISC::CRGBA getValueColor(const CHtmlElement &elm, CCssStyle &style) const; + + float value; + float min; + float max; + float low; + float high; + float optimum; + }; + + class HTMLProgressElement + { + public: + HTMLProgressElement() + : value(0.f), max(1.f) + {} + + // read attributes from html element + void readValues(const CHtmlElement &elm); + + // return value ratio to min-max + float getValueRatio() const; + + // return meter bar color + NLMISC::CRGBA getBarColor(const CHtmlElement &elm, CCssStyle &style) const; + + // return meter value bar color based value and optimum range + NLMISC::CRGBA getValueColor(const CHtmlElement &elm, CCssStyle &style) const; + + float value; + float max; + }; + // A mode std::vector _A; inline bool getA() const @@ -539,33 +553,18 @@ namespace NLGUI // IL mode bool _LI; - // Current active style - CStyleParams _Style; - // Default style - CStyleParams _StyleDefault; - // Nested style stack - std::vector _StyleParams; - inline void pushStyle() - { - _StyleParams.push_back(_Style); - } - inline void popStyle() - { - if (_StyleParams.empty()) - _Style = _StyleDefault; - else - { - _Style = _StyleParams.back(); - _StyleParams.pop_back(); - } - } + // style from browser.css + CCssStyle _BrowserStyle; + // local file for browser.css + std::string _BrowserCssFile; - inline uint getFontSizeSmaller() const - { - if (_Style.FontSize < 5) - return 3; - return _Style.FontSize-2; - } + // Keep track of current element style + CCssStyle _Style; + CHtmlElement _HtmlDOM; + CHtmlElement *_CurrentHTMLElement; + // Backup of CurrentHTMLElement->nextSibling before ::beginElement() is called + // for luaParseHtml() to insert nodes into right place in right order + CHtmlElement *_CurrentHTMLNextSibling; // Current link std::vector _Link; @@ -591,14 +590,6 @@ namespace NLGUI return _LinkClass.back().c_str(); } - std::vector _BlockLevelElement; - inline bool isBlockLevelElement() const - { - if (_BlockLevelElement.empty()) - return false; - return _BlockLevelElement.back(); - } - // Divs (i.e. interface group) std::vector _Divs; inline CInterfaceGroup *getDiv() const @@ -629,14 +620,6 @@ namespace NLGUI return _TR.back(); } - std::vector _TextShadow; - inline STextShadow getTextShadow() const - { - if (_TextShadow.empty()) - return STextShadow(); - return _TextShadow.back(); - } - // Forms class CForm { @@ -690,6 +673,9 @@ namespace NLGUI sint InitialSelection; // initial selection for the combo box }; + //
element "id" attribute + std::string id; + // The action the form has to perform std::string Action; @@ -697,6 +683,27 @@ namespace NLGUI std::vector Entries; }; std::vector _Forms; + // if element has been closed or not + bool _FormOpen; + + // submit buttons added to from + struct SFormSubmitButton + { + SFormSubmitButton(const std::string &form, const std::string &name, const std::string &value, const std::string &type, const std::string &formAction="") + : form(form), name(name), value(value), type(type), formAction(formAction) + { } + + std::string form; // form 'id' + std::string name; // submit button name + std::string value; // submit button value + std::string type; // button type, ie 'image' + + std::string formAction; // override form action attribute (url) + }; + + // submit buttons added to form + std::vector _FormSubmit; + std::vector _Groups; // Cells parameters @@ -709,6 +716,7 @@ namespace NLGUI VAlign = CGroupCell::Middle; LeftMargin = 0; NoWrap = false; + Height = 0; } NLMISC::CRGBA BgColor; std::string Style; @@ -716,6 +724,7 @@ namespace NLGUI CGroupCell::TVAlign VAlign; sint32 LeftMargin; bool NoWrap; + sint32 Height; }; std::vector _CellParams; @@ -726,7 +735,7 @@ namespace NLGUI return 0; return _Indent.back(); } - + // Current node is a title @@ -798,10 +807,6 @@ namespace NLGUI typedef std::map > TGroupHtmlByUIDMap; static TGroupHtmlByUIDMap _GroupHtmlByUID; - // read style attribute - void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams ¤t); - void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0); - // load and render local html file (from bnp for example) void doBrowseLocalFile(const std::string &filename); @@ -815,9 +820,14 @@ namespace NLGUI void buildHTTPPostParams (SFormFields &formfields); private: + friend class CHtmlParser; + + // move src->Children into CurrentHtmlElement.parent.children element + void spliceFragment(std::list::iterator src); + // decode all HTML entities static ucstring decodeHTMLEntities(const ucstring &str); - + struct CDataImageDownload { public: @@ -834,10 +844,11 @@ namespace NLGUI { public: CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams(), const TImageType imagetype = NormalImage) - : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0) + : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0), ConnectionTimeout(60) { if (t == ImgType) imgs.push_back(CDataImageDownload(i, style, imagetype)); } + ~CDataDownload(); public: CCurlWWWData *data; @@ -849,13 +860,16 @@ namespace NLGUI uint32 redirects; FILE *fp; std::vector imgs; + uint32 ConnectionTimeout; }; - std::vector Curls; + std::list Curls; CURLM *MultiCurl; int RunningCurls; bool startCurlDownload(CDataDownload &download); + void finishCurlDownload(const CDataDownload &download); + void pumpCurlQueue(); void initImageDownload(); void checkImageDownload(); @@ -874,11 +888,125 @@ namespace NLGUI bool addBnpDownload(std::string url, const std::string &action, const std::string &script, const std::string &md5sum); std::string localBnpName(const std::string &url); + // add css file from to download queue + void addStylesheetDownload(std::vector links); + + // stop all curl downalods (html and data) void releaseDownloads(); void checkDownloads(); + // _CurlWWW download finished + void htmlDownloadFinished(bool success, const std::string &error); + // images, stylesheets, etc finished downloading + void dataDownloadFinished(bool success, const std::string &error, CDataDownload &data); + // HtmlType download finished void htmlDownloadFinished(const std::string &content, const std::string &type, long code); + + // stylesheet finished downloading. if local file does not exist, then it failed (404) + void cssDownloadFinished(const std::string &url, const std::string &local); + + // read common table/tr/td parameters and push them to _CellParams + void getCellsParameters(const CHtmlElement &elm, bool inherit); + + // render _HtmlDOM + void renderDocument(); + + // :before, :after rendering + void renderPseudoElement(const std::string &pseudo, const CHtmlElement &elm); + + // apply background from current style (for html, body) + void applyBackground(const CHtmlElement &elm); + + void insertFormImageButton(const std::string &name, + const std::string &tooltip, + const std::string &src, + const std::string &over, + const std::string &formId, + const std::string &formAction = "", + uint32 minWidth = 0, + const std::string &templateName = ""); + + void insertFormTextButton(const std::string &name, + const std::string &tooltip, + const std::string &value, + const std::string &formId, + const std::string &formAction = "", + uint32 minWidth = 0, + const std::string &templateName = ""); + + // HTML elements + void htmlA(const CHtmlElement &elm); + void htmlAend(const CHtmlElement &elm); + void htmlBASE(const CHtmlElement &elm); + void htmlBODY(const CHtmlElement &elm); + void htmlBR(const CHtmlElement &elm); + void htmlBUTTON(const CHtmlElement &elm); + void htmlBUTTONend(const CHtmlElement &elm); + void htmlDD(const CHtmlElement &elm); + void htmlDDend(const CHtmlElement &elm); + //void htmlDEL(const CHtmlElement &elm); + void htmlDIV(const CHtmlElement &elm); + void htmlDIVend(const CHtmlElement &elm); + void htmlDL(const CHtmlElement &elm); + void htmlDLend(const CHtmlElement &elm); + void htmlDT(const CHtmlElement &elm); + void htmlDTend(const CHtmlElement &elm); + //void htmlEM(const CHtmlElement &elm); + void htmlFONT(const CHtmlElement &elm); + void htmlFORM(const CHtmlElement &elm); + void htmlFORMend(const CHtmlElement &elm); + void htmlH(const CHtmlElement &elm); + void htmlHend(const CHtmlElement &elm); + void htmlHEAD(const CHtmlElement &elm); + void htmlHEADend(const CHtmlElement &elm); + void htmlHR(const CHtmlElement &elm); + void htmlHTML(const CHtmlElement &elm); + void htmlI(const CHtmlElement &elm); + void htmlIend(const CHtmlElement &elm); + void htmlIMG(const CHtmlElement &elm); + void htmlINPUT(const CHtmlElement &elm); + void htmlLI(const CHtmlElement &elm); + void htmlLIend(const CHtmlElement &elm); + void htmlLUA(const CHtmlElement &elm); + void htmlLUAend(const CHtmlElement &elm); + void htmlMETA(const CHtmlElement &elm); + void htmlMETER(const CHtmlElement &elm); + void htmlOBJECT(const CHtmlElement &elm); + void htmlOBJECTend(const CHtmlElement &elm); + void htmlOL(const CHtmlElement &elm); + void htmlOLend(const CHtmlElement &elm); + void htmlOPTION(const CHtmlElement &elm); + void htmlOPTIONend(const CHtmlElement &elm); + void htmlP(const CHtmlElement &elm); + void htmlPend(const CHtmlElement &elm); + void htmlPRE(const CHtmlElement &elm); + void htmlPREend(const CHtmlElement &elm); + void htmlPROGRESS(const CHtmlElement &elm); + void htmlSCRIPT(const CHtmlElement &elm); + void htmlSCRIPTend(const CHtmlElement &elm); + void htmlSELECT(const CHtmlElement &elm); + void htmlSELECTend(const CHtmlElement &elm); + //void htmlSMALL(const CHtmlElement &elm); + //void htmlSPAN(const CHtmlElement &elm); + //void htmlSTRONG(const CHtmlElement &elm); + void htmlSTYLE(const CHtmlElement &elm); + void htmlSTYLEend(const CHtmlElement &elm); + void htmlTABLE(const CHtmlElement &elm); + void htmlTABLEend(const CHtmlElement &elm); + void htmlTD(const CHtmlElement &elm); + void htmlTDend(const CHtmlElement &elm); + void htmlTEXTAREA(const CHtmlElement &elm); + void htmlTEXTAREAend(const CHtmlElement &elm); + void htmlTH(const CHtmlElement &elm); + void htmlTHend(const CHtmlElement &elm); + void htmlTITLE(const CHtmlElement &elm); + void htmlTITLEend(const CHtmlElement &elm); + void htmlTR(const CHtmlElement &elm); + void htmlTRend(const CHtmlElement &elm); + //void htmlU(const CHtmlElement &elm); + void htmlUL(const CHtmlElement &elm); + void htmlULend(const CHtmlElement &elm); }; // adapter group that store y offset for inputs inside an html form diff --git a/code/nel/include/nel/gui/group_list.h b/code/nel/include/nel/gui/group_list.h index a86950d3e..58af530b5 100644 --- a/code/nel/include/nel/gui/group_list.h +++ b/code/nel/include/nel/gui/group_list.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h index cfe91f7f9..21a740d84 100644 --- a/code/nel/include/nel/gui/group_menu.h +++ b/code/nel/include/nel/gui/group_menu.h @@ -1,5 +1,9 @@ // Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2010-2019 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2014 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -136,6 +140,13 @@ namespace NLGUI void removeLine(uint index); const std::string getActionHandler(uint lineIndex) const; const std::string getActionHandlerParam(uint lineIndex) const; + const std::string getRightClickHandler(uint lineIndex) const; + const std::string getRightClickHandlerParam(uint lineIndex) const; + + void setActionHandler(uint lineIndex, const std::string &ah = ""); + void setActionHandlerParam(uint lineIndex, const std::string ¶ms = ""); + void setRightClickHandler(uint lineIndex, const std::string &ah = ""); + void setRightClickHandlerParam(uint lineIndex, const std::string ¶ms = ""); void openSubMenu (sint32 nb); @@ -232,6 +243,8 @@ namespace NLGUI CInterfaceGroup *Separator; std::string AHName; std::string AHParams; + std::string AHRightClick; + std::string AHRightClickParams; std::string Id; std::string Cond; // condition to know if the entry is grayed CViewBitmap *CheckBox; @@ -329,7 +342,13 @@ namespace NLGUI void deleteLine(uint index); const std::string getActionHandler(uint lineIndex) const; const std::string getActionHandlerParam(uint lineIndex) const; + const std::string getRightClickHandler(uint lineIndex) const; + const std::string getRightClickHandlerParam(uint lineIndex) const; + void setActionHandler(uint lineIndex, const std::string &ah = ""); + void setActionHandlerParam(uint lineIndex, const std::string ¶ms = ""); + void setRightClickHandler(uint lineIndex, const std::string &ah = ""); + void setRightClickHandlerParam(uint lineIndex, const std::string ¶ms = ""); void addLine (const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", const std::string &id = std::string(), @@ -352,7 +371,7 @@ namespace NLGUI void setMinH(sint32 minH); // change fontsize for new menu items - void setFontSize(uint32 fontSize); + void setFontSize(uint32 fontSize, bool coef = true); // Gray a line on the RootMenu void setGrayedLine(uint line, bool g); @@ -392,6 +411,7 @@ namespace NLGUI bool _Formatted; uint8 _Space; sint32 _FontSize; + bool _FontSizeCoef; NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it diff --git a/code/nel/include/nel/gui/group_modal.h b/code/nel/include/nel/gui/group_modal.h index c177d6f0c..83687b562 100644 --- a/code/nel/include/nel/gui/group_modal.h +++ b/code/nel/include/nel/gui/group_modal.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_paragraph.h b/code/nel/include/nel/gui/group_paragraph.h index 02f948582..6142bc33b 100644 --- a/code/nel/include/nel/gui/group_paragraph.h +++ b/code/nel/include/nel/gui/group_paragraph.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_scrolltext.h b/code/nel/include/nel/gui/group_scrolltext.h index 66fc89044..b9916aec8 100644 --- a/code/nel/include/nel/gui/group_scrolltext.h +++ b/code/nel/include/nel/gui/group_scrolltext.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_submenu_base.h b/code/nel/include/nel/gui/group_submenu_base.h index ada94bfa6..16e3a5c77 100644 --- a/code/nel/include/nel/gui/group_submenu_base.h +++ b/code/nel/include/nel/gui/group_submenu_base.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_tab.h b/code/nel/include/nel/gui/group_tab.h index ee68acbc8..fc05c5ae0 100644 --- a/code/nel/include/nel/gui/group_tab.h +++ b/code/nel/include/nel/gui/group_tab.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/group_table.h b/code/nel/include/nel/gui/group_table.h index 2be9ef98c..e23ea5af8 100644 --- a/code/nel/include/nel/gui/group_table.h +++ b/code/nel/include/nel/gui/group_table.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -23,9 +26,11 @@ #include "nel/gui/group_frame.h" #include "nel/gui/view_text.h" #include "nel/gui/ctrl_button.h" +#include "nel/gui/css_types.h" namespace NLGUI { + class CSSBorderRenderer; /** * This group is used to simulate HTML cells. @@ -39,6 +44,7 @@ namespace NLGUI DECLARE_UI_CLASS( CGroupCell ) CGroupCell(const TCtorParam ¶m); + ~CGroupCell(); enum TAlign { @@ -91,11 +97,18 @@ namespace NLGUI // The cell color NLMISC::CRGBA BgColor; + CSSBorderRenderer* Border; + uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft; + // Texture - CViewRenderer::CTextureId _TextureId; /// Accelerator - bool _UserTexture; + CViewRenderer::CTextureId _TextureId; bool _TextureTiled; bool _TextureScaled; + // cached absolute coords for background texture + sint32 _TextureXReal; + sint32 _TextureYReal; + sint32 _TextureWReal; + sint32 _TextureHReal; // Alignment TAlign Align; @@ -112,10 +125,17 @@ namespace NLGUI void setTextureTile(bool tiled); void setTextureScale(bool scaled); + uint32 getPaddingLeftRight() const { return PaddingLeft + PaddingRight; }; + uint32 getPaddingTopBottom() const { return PaddingTop + PaddingBottom; }; + + virtual void updateCoords(); + static void setDebugUICell( bool d ){ DebugUICell = d; } static bool getDebugUICell(){ return DebugUICell; } private: + void updateTextureCoords(); + void setEnclosedGroupDefaultParams(); static bool DebugUICell; }; @@ -143,9 +163,10 @@ namespace NLGUI // The Width you want in pixel. This is the parameter sint32 ForceWidthMin; - // Table borders - sint32 Border; - NLMISC::CRGBA BorderColor; + CSSBorderRenderer* Border; + + // Cell has 1px solid border when
has 'border' attribute with width > 0 + bool CellBorder; sint32 CellPadding; sint32 CellSpacing; @@ -155,6 +176,10 @@ namespace NLGUI bool ContinuousUpdate; + void setTexture(const std::string & TxName); + void setTextureTile(bool tiled); + void setTextureScale(bool scaled); + std::string getProperties( const std::string &name ) const; void setProperty( const std::string &name, const std::string &value ); xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; @@ -176,6 +201,18 @@ namespace NLGUI virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + // Texture + CViewRenderer::CTextureId _TextureId; + bool _TextureTiled; + bool _TextureScaled; + // cached absolute coords for background texture + sint32 _TextureXReal; + sint32 _TextureYReal; + sint32 _TextureWReal; + sint32 _TextureHReal; + + void updateTextureCoords(); + // Content validated bool _ContentValidated; diff --git a/code/nel/include/nel/gui/group_tree.h b/code/nel/include/nel/gui/group_tree.h index ae4bcb3d0..266e7e23f 100644 --- a/code/nel/include/nel/gui/group_tree.h +++ b/code/nel/include/nel/gui/group_tree.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -178,7 +181,7 @@ namespace NLGUI REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); REFLECT_BOOL("Opened", getOpened, setOpened); REFLECT_BOOL("Show", getShow, setShow); - REFLECT_UCSTRING("Text", getText, setText); + REFLECT_UCSTRING_REF("Text", getText, setText); // lua REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); REFLECT_LUA_METHOD("getChild", luaGetChild); diff --git a/code/nel/include/nel/gui/group_wheel.h b/code/nel/include/nel/gui/group_wheel.h index c61b92dfd..40d81cff0 100644 --- a/code/nel/include/nel/gui/group_wheel.h +++ b/code/nel/include/nel/gui/group_wheel.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/nel/include/nel/gui/html_element.h b/code/nel/include/nel/gui/html_element.h new file mode 100644 index 000000000..b7bceb4ab --- /dev/null +++ b/code/nel/include/nel/gui/html_element.h @@ -0,0 +1,94 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_HTML_ELEMENT_H +#define CL_HTML_ELEMENT_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/css_style.h" + +namespace NLGUI +{ + /** + * \brief HTML element + * \date 2019-04-25 18:23 GMT + * \author Meelis Mägi (Nimetu) + */ + class CHtmlElement + { + public: + enum ENodeType { + NONE = 0, + ELEMENT_NODE = 1, + TEXT_NODE = 3, + }; + + uint ID; // libwww element enum + ENodeType Type; + std::string Value; // text node value or element node name + std::map Attributes; + std::list Children; + + // class names for css matching + std::set ClassNames; + + // defined style and :before/:after pseudo elements + TStyle Style; + + // hierarchy + CHtmlElement *parent; + CHtmlElement *previousSibling; + CHtmlElement *nextSibling; + + // n'th ELEMENT_NODE in parent.Children, for :nth-child() rules + uint childIndex; + + CHtmlElement(ENodeType type = NONE, std::string value = ""); + + // returns true if rhs is same pointer + friend bool operator==(const CHtmlElement &lhs, const CHtmlElement &rhs) + { + return &lhs == &rhs; + } + + bool hasAttribute(const std::string &key) const; + + bool hasNonEmptyAttribute(const std::string &key) const; + + std::string getAttribute(const std::string &key) const; + + bool hasClass(const std::string &key) const; + + // update Children index/parent/next/prevSibling pointers + void reindexChilds(); + + // debug + std::string toString(bool tree = false, uint depth = 0) const; + + // query, get, set pseudo element style rules + void clearPseudo(); + bool hasPseudo(const std::string &key) const; + TStyle getPseudo(const std::string &key) const; + void setPseudo(const std::string &key, const TStyle &style); + + private: + // pseudo elements like ":before" and ":after" + std::map _Pseudo; + }; +} + +#endif + diff --git a/code/nel/include/nel/gui/html_parser.h b/code/nel/include/nel/gui/html_parser.h new file mode 100644 index 000000000..760640234 --- /dev/null +++ b/code/nel/include/nel/gui/html_parser.h @@ -0,0 +1,52 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_HTML_PARSER_H +#define CL_HTML_PARSER_H + +#include "nel/misc/types_nl.h" + +namespace NLGUI +{ + class CHtmlElement; + + /** + * \brief HTML parsing + * \date 2019-03-15 10:50 GMT + * \author Meelis Mägi (Nimetu) + */ + class CHtmlParser + { + public: + bool parseHtml(std::string htmlString) const; + + // parse html string into DOM, extract + bool useStyle = true; + if (elm.hasAttribute("media")) + { + std::string media = trim(toLower(elm.Attributes["media"])); + useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos; + + // + Ryzom Installer + + + +
+ + + +
+ + + + + + + + + + + + + + + + +
+ + + + Kostenlosen Account erstellen + +
+ + + + Ryzom Features + +
+ + + + Forum für neue Spieler + +
+ + + + Problemhilfe + +
+ + + + diff --git a/code/ryzom/tools/client/client_install/www/client_install/client_install_en.htm b/code/ryzom/tools/client/client_install/www/client_install/client_install_en.htm new file mode 100644 index 000000000..3061a929a --- /dev/null +++ b/code/ryzom/tools/client/client_install/www/client_install/client_install_en.htm @@ -0,0 +1,84 @@ + + + + + + Ryzom Installer + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + Create Free Trial Account + +
+ + + + Features of Ryzom + +
+ + + + Newcomer Welcome Board + +
+ + + + Troubleshooting + +
+
+ + + diff --git a/code/ryzom/tools/client/client_install/www/client_install/client_install_fr.htm b/code/ryzom/tools/client/client_install/www/client_install/client_install_fr.htm new file mode 100644 index 000000000..1a66d44d4 --- /dev/null +++ b/code/ryzom/tools/client/client_install/www/client_install/client_install_fr.htm @@ -0,0 +1,84 @@ + + + + + + Ryzom Installer + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + Créer un Compte + +
+ + + + Présentation de Ryzom + +
+ + + + Accueil des Nouveaux Joueurs + +
+ + + + Assistance + +
+
+ + + diff --git a/code/ryzom/tools/client/client_install/www/client_install/installer.psd b/code/ryzom/tools/client/client_install/www/client_install/installer.psd new file mode 100644 index 000000000..4b7b111f8 Binary files /dev/null and b/code/ryzom/tools/client/client_install/www/client_install/installer.psd differ diff --git a/code/ryzom/tools/client/client_install/www/client_install/lore.gif b/code/ryzom/tools/client/client_install/www/client_install/lore.gif new file mode 100644 index 000000000..d0a2539d7 Binary files /dev/null and b/code/ryzom/tools/client/client_install/www/client_install/lore.gif differ diff --git a/code/ryzom/tools/client/client_install/www/client_install/rn.gif b/code/ryzom/tools/client/client_install/www/client_install/rn.gif new file mode 100644 index 000000000..9d598548c Binary files /dev/null and b/code/ryzom/tools/client/client_install/www/client_install/rn.gif differ diff --git a/code/ryzom/tools/client/client_install/www/client_install/subscribe.gif b/code/ryzom/tools/client/client_install/www/client_install/subscribe.gif new file mode 100644 index 000000000..bb4777813 Binary files /dev/null and b/code/ryzom/tools/client/client_install/www/client_install/subscribe.gif differ diff --git a/code/ryzom/tools/client/client_install/www/struct.sql b/code/ryzom/tools/client/client_install/www/struct.sql new file mode 100644 index 000000000..52fb39ffd --- /dev/null +++ b/code/ryzom/tools/client/client_install/www/struct.sql @@ -0,0 +1,85 @@ +-- phpMyAdmin SQL Dump +-- version 2.6.1 +-- http://www.phpmyadmin.net +-- +-- Serveur: localhost +-- Généré le : Vendredi 09 Mars 2007 ŕ 15:00 +-- Version du serveur: 4.1.9 +-- Version de PHP: 4.3.10 +-- +-- Base de données: `stats` +-- + +-- -------------------------------------------------------- + +-- +-- Structure de la table `install_users` +-- + +DROP TABLE IF EXISTS `install_users`; +CREATE TABLE IF NOT EXISTS `install_users` ( + `user_id` int(11) NOT NULL default '0', + `install_id` int(11) NOT NULL default '0', + `first_install` datetime NOT NULL default '0000-00-00 00:00:00', + `last_install` datetime NOT NULL default '0000-00-00 00:00:00', + `install_count` tinyint(4) NOT NULL default '0', + `os` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `proc` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `memory` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `video_card` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `driver_version` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `state` tinytext character set latin1 collate latin1_general_cs NOT NULL, + PRIMARY KEY (`user_id`), + KEY `install_id` (`install_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `log` +-- + +DROP TABLE IF EXISTS `log`; +CREATE TABLE IF NOT EXISTS `log` ( + `log_id` int(11) NOT NULL auto_increment, + `log` text character set latin1 collate latin1_general_cs NOT NULL, + PRIMARY KEY (`log_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=687 ; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `sessions` +-- + +DROP TABLE IF EXISTS `sessions`; +CREATE TABLE IF NOT EXISTS `sessions` ( + `session_id` int(11) NOT NULL default '0', + `user_id` int(11) NOT NULL default '0', + `server` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `application` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `version` int(11) NOT NULL default '0', + `ip` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `lang` varchar(5) character set latin1 collate latin1_general_cs NOT NULL default '', + `type` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `package` varchar(10) character set latin1 collate latin1_general_cs NOT NULL default '', + `protocol` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `size_download` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `size_install` tinytext character set latin1 collate latin1_general_cs NOT NULL, + `start_download` datetime NOT NULL default '0000-00-00 00:00:00', + `stop_download` datetime NOT NULL default '0000-00-00 00:00:00', + `start_install` datetime NOT NULL default '0000-00-00 00:00:00', + `stop_install` timestamp NOT NULL default '0000-00-00 00:00:00', + `percent_download` int(11) NOT NULL default '0', + `percent_install` int(11) NOT NULL default '0', + `previous_download` tinytext character set latin1 collate latin1_general_cs NOT NULL, + PRIMARY KEY (`session_id`), + KEY `start_download` (`start_download`), + KEY `user_id` (`user_id`), + KEY `percent_download` (`percent_download`), + KEY `percent_install` (`percent_install`), + KEY `lang` (`lang`), + KEY `package` (`package`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + diff --git a/code/ryzom/tools/client/client_multi/client.cfg b/code/ryzom/tools/client/client_multi/client.cfg new file mode 100644 index 000000000..28399bd1a --- /dev/null +++ b/code/ryzom/tools/client/client_multi/client.cfg @@ -0,0 +1,20 @@ +RootConfigFilename = "client_default.cfg"; +FSHost = "localhost"; +FullScreen = 0; +DisableDirectInput = 1; +SoundOn = 0; +Local = 0; +ClientVersion = "0.5.9.85"; +Width = 800; +Height = 599; +PositionX = 0; +PositionY = 1; +UpdatePackedSheet = 1; +SimInLag = { }; +SimInPacketLost = { }; +SimOutLag = { }; +SimOutPacketLost = { }; +SimOutPacketDuplication = { }; +SimOutPacketDisordering = { }; +NbConnections = 200; +UserId = 11; diff --git a/code/ryzom/tools/client/client_multi/commands.cpp b/code/ryzom/tools/client/client_multi/commands.cpp new file mode 100644 index 000000000..832e28682 --- /dev/null +++ b/code/ryzom/tools/client/client_multi/commands.cpp @@ -0,0 +1,2856 @@ +/** \file commands.cpp + * File with all the commands for the console. + * + * $Id: commands.cpp,v 1.8 2004/06/23 15:03:04 lecroart Exp $ + */ + + + + +////////////// +// Includes // +////////////// +#include "stdpch.h" +// Game Share +#include "game_share/generic_xml_msg_mngr.h" +#include "game_share/visual_slot_manager.h" +// Misc. +#include "nel/misc/command.h" +#include "nel/misc/i18n.h" +#include "nel/misc/bit_mem_stream.h" +// 3D Interface. +#include "nel/3d/u_scene.h" +#include "nel/3d/u_landscape.h" +#include "nel/3d/u_play_list.h" +#include "nel/3d/u_animation_set.h" +#include "nel/3d/u_animation.h" +#include "nel/3d/u_track.h" +#include "nel/3d/u_play_list_manager.h" +// Client. +#include "interface_manager.h" +#include "commands.h" +#include "user_entity.h" +#include "entity_animation_manager.h" +#include "firework.h" +#include "view.h" +#include "time_client.h" +#include "entities.h" +#include "world_database_manager.h" +#include "continent_manager.h" +#include "continent.h" +#include "ig_client.h" +#include "ingame_database_manager.h" +#include "client_chat_manager.h" +#include "net_manager.h" +#include "pacs_client.h" +#include "teleport.h" +#include "misc.h" +#include "sheet_manager.h" +#include "demo.h" +#include "sound_manager.h" +#include "cdb_leaf.h" +#include "debug_client.h" +#include "input_handler_manager.h" +// game share +#include "game_share/brick_types.h" +#include "game_share/player_visual_properties.h" +#include "game_share/ryzom_version.h" +#include "game_share/mode_and_behaviour.h" +#include "brick_manager.h" + + +//////////// +// DEFINE // +//////////// +//#define _LIMITED_COMMAND_ // Disable some commands +#define _CMD_CHEAT_ON_ // Activate cheat commands +#define _CMD_TEST_ON_ // Activate test commands +#define _CMD_DEBUG_ON_ // Activate debug commands + + +//////////////// +// Namespaces // +//////////////// +using namespace NLMISC; +using namespace NL3D; +using namespace NLNET; +using namespace std; + + +///////////// +// Externs // +///////////// +extern CUserEntity UserEntity; +extern UScene * Scene; +extern ULandscape * Landscape; +extern CEntityAnimationManager * EAM; +extern CFirework * Firework; +extern CClientChatManager ChatMngr; +extern CGenericXmlMsgHeaderManager GenericMsgHeaderMngr; +extern ::CNetManagerMulti NetMngr; +extern CInterfaceManager *IM; + + +////////////// +// COMMANDS // +////////////// +//////////////////// +// FINAL COMMANDS // +//----------------------------------------------- +// 'emote' : play an emote. +//----------------------------------------------- +NLMISC_COMMAND(emote, "play an emote.", "") +{ + const uint nbEmotes = EAM->getNbEmots(); + + // Check parameters. + if(args.size() == 1) + { + // Check the number is valid. + uint num = atoi(args[0].c_str()); + if(num < nbEmotes) + { + // Create the message and send. + const string msgName = "COMMAND:EMOTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + MBEHAV::EBehaviour behaviour = (MBEHAV::EBehaviour)(MBEHAV::EMOTE_BEGIN + num); + out.serialEnum(behaviour); + NetMngr.push(out); + } + else + nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + + // Command Well done. + return true; + } + } + + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 1 paramter and this must be one of the following number :")); + CAnimationState::TAnimStateId result; + for(uint i = 0; igetEmot(i, result); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString("%d - %s", i, CAnimationState::getAnimationStateName(result).c_str ()))); + } + + // Command Well done. + return true; +}// chat_mode // + +//----------------------------------------------- +// 'guildSymbol' : Show/Hide the Guild Symbol. +//----------------------------------------------- +NLMISC_COMMAND(guildSymbol, "Show/Hide the Guild Symbol.", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + // Invert the state. + GuildSymbol.Active = !GuildSymbol.Active; + + // Command Well done. + return true; +}// chat_mode // + +//----------------------------------------------- +// 'chatMode' : To specify how you will speak and who will be able to hear you. +//----------------------------------------------- +NLMISC_COMMAND(chatMode, "To specify how will you speak and who will be able to hear you.", "") +{ + // Check parameters. + if(args.size() != 1) + return false; + + CInputHandlerManager *pIHM = CInputHandlerManager::getInstance(); + + uint8 mode ; + if (args[0] == "say") + mode = 0; + else if(args[0] == "shout") + mode = 1; + else if(args[0] == "universe") + mode = 2; + else if(args[0] == "team") + mode = 3; + else if(args[0] == "clade") + mode = 4; + else + { + nlwarning("Command 'chatMode': unknown chat mode '%s'.", args[0].c_str()); + return false; + } + // Display debug info. + nlinfo("Command 'chatMode': '%s' mode.", args[0].c_str()); + // Set the chat mode. + ChatMngr.setChatMode(mode); + // Command Well done. + return true; +}// chat_mode // + +//----------------------------------------------- +// 'tell' : send a private message to a unique player. +//----------------------------------------------- +NLMISC_COMMAND(tell, "send a private message to a unique player", "") +{ + // Check parameters. + if(args.size() < 2) + return false; + + // Compute the message. + string message; + for(uint i=1; i") +{ + const char *brname[] = { "bug_report.exe", "bug_report_r.exe", "bug_report_rd.exe", "bug_report_df.exe", "bug_report_d.exe" }; + + string brn; + + for (uint i = 0; i < sizeof(brname)/sizeof(brname[0]); i++) + { + if (CFile::fileExists (brname[i])) + { + brn = brname[i]; + break; + } + } + + if (brn.empty()) + { + log.displayNL("bug_report*.exe not found"); + return false; + } + + string sys; + + sys = "Language "+CI18N::getCurrentLanguageName().toString() +" "; + + if (args.size()>0) + { + uint8 quality = atoi (args[0].c_str()); + if (quality == 0) + quality = 80; + + CBitmap btm; + Driver->getBuffer(btm); + string filename = CFile::findNewFile ("screenshot.jpg"); + COFile fs(filename); + btm.writeJPG(fs, quality); + sys += "AttachedFile "+filename+" "; + } + + sys += "ClientVersion "RYZOM_VERSION" "; + + // for now, set the same version than client one + sys += "ShardVersion "RYZOM_VERSION" "; + + if (ClientCfg.Local) + sys += "ShardName OFFLINE "; + + FILE *fp = fopen ("bug_report.txt", "wb"); + if (fp != NULL) + { + // must put \r\n each line + fprintf (fp, "UserPosition: %.2f %.2f %.2f\r\n", View.viewPos().x, View.viewPos().y, View.viewPos().z); + fprintf (fp, "ServerTick: %u\r\n", NetMngr.getCurrentServerTick() ); + fprintf (fp, "LocalAddress: %s\r\n", NetMngr.getAddress().asString().c_str() ); +// TODO add debug information for the bug report + + fclose (fp); + sys += "DumpFilename bug_report.txt "; + } + + nlinfo ("Calling for bug report : '%s %s'", brn.c_str(), sys.c_str()); + + launchProgram(brn, sys); + + return true; +} + + + +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +/////////// COMMANDS after should NOT appear IN the FINAL VERSION /////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + + +#if !FINAL_VERSION + +NLMISC_COMMAND(missionReward, "debug"," ") +{ + if (args.size() == 1) + { + uint8 index = atoi( args[1].c_str() ); + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("BOTCHAT:COMPLETE_MISSION", out)) + { + out.serial(index); + NetMngr.push(out); + } + else + nlwarning(" : unknown message name : BOTCHAT:COMPLETE_MISSION"); + return true; + } + return false; +} + +NLMISC_COMMAND(missionProgress, "debug"," ") +{ + if (args.size() == 1) + { + uint8 index = atoi( args[1].c_str() ); + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("BOTCHAT:PROGRESS_MISSION", out)) + { + out.serial(index); + NetMngr.push(out); + } + else + nlwarning(" : unknown message name : BOTCHAT:PROGRESS_MISSION"); + return true; + } + return false; +} + +/* +NLMISC_COMMAND( displayDBModifs, "display server database modification in the chat window"," ") +{ + if ( VerboseDatabase ) + CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already in verbose mode"),CRGBA(255,255,255,255)); + else + { + CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is now in verbose mode"),CRGBA(255,255,255,255)); + VerboseDatabase = true; + } + return true; +} + +NLMISC_COMMAND( hideDBModifs, "stop displaying server database modification in the chat window"," ") +{ + if ( !VerboseDatabase ) + CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already not in verbose mode"),CRGBA(255,255,255,255)); + else + { + CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is not in verbose mode anymore"),CRGBA(255,255,255,255)); + VerboseDatabase = false; + } + return true; +} +*/ + +NLMISC_COMMAND(save_sentences, "save sentences"," ") +{ +// CSentenceDisplayer::saveSentences(); + return true; +} + +NLMISC_COMMAND(get_sheet_id, "get_sheet_id","") +{ + if (args.size() != 1) + return false; + CSheetId id(args[0]); + + char buf[10]; + itoa( id.asInt(),buf,10 ); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(buf)); + return true; +} + +NLMISC_COMMAND(get_sheet_name, "get_sheet_name","") +{ + if (args.size() != 1) + return false; + CSheetId id( atoi(args[0].c_str()) ); + + string name = id.toString(); + + + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name)); + return true; +} + +NLMISC_COMMAND(forget_all, "forget all bricks", "") +{ + // Check parameters. + if(args.size() != 0) + { + return false; + } + char buf[100]; + for (uint i = 0;i<20;i++) + { + sprintf(buf,"SERVER:BRICK_FAMILY:%d:BRICKS",i); + CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(buf); + node->setValue64(0); + } + return true; + +} // forget_all // + + + +//----------------------------------------------- +// 'use_preprog_magic' +//----------------------------------------------- +NLMISC_COMMAND(use_preprog_magic, "use the specified magic preprog sentence", "") +{ + // Check parameters. + if(args.size() != 1) + { + return false; + } + + // Create the message for the server to execute a phrase. + const string msgName = "SENTENCE:EXECUTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("SENTENCE:EXECUTE", out)) + { + uint8 phrase = atoi(args[0].c_str() ); + out.serial(phrase); + + BRICK_TYPE::EBrickType type = BRICK_TYPE::MAGIC; + out.serialEnum( type ); + + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; + +} // use_preprog_magic // + + + + +//----------------------------------------------- +// 'use_preprog_combat' +//----------------------------------------------- +NLMISC_COMMAND(use_preprog_combat, "use the specified combat preprog sentence", "") +{ + // Check parameters. + if(args.size() != 1) + { + return false; + } + + // Create the message for the server to execute a phrase. + const string msgName = "SENTENCE:EXECUTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("SENTENCE:EXECUTE", out)) + { + uint8 phrase = atoi(args[0].c_str() ); + out.serial(phrase); + + BRICK_TYPE::EBrickType type = BRICK_TYPE::COMBAT; + out.serialEnum( type ); + + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; + +} // use_preprog_combat // + + + +//----------------------------------------------- +// 'engage' +//----------------------------------------------- +NLMISC_COMMAND(engage, "engage target in combat", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "COMBAT:ENGAGE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // engage // + + +//----------------------------------------------- +// 'default_attack' +//----------------------------------------------- +NLMISC_COMMAND(default_attack, "use default attack on target", "") +{ + // Default attack on the current selection. + UserEntity.attack(); + + // Well Done. + return true; +}// default_attack // + +//----------------------------------------------- +// 'disengage' +//----------------------------------------------- +NLMISC_COMMAND(disengage, "disengage from combat", "") +{ + // Disengage from combat. + UserEntity.disengage(); + + // Well Done. + return true; +}// disengage // + +//----------------------------------------------- +// 'create_team' +//----------------------------------------------- +NLMISC_COMMAND(create_team, "create a new team", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "TEAM:CREATE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // create_team // + + +//----------------------------------------------- +// 'leave_team' +//----------------------------------------------- +NLMISC_COMMAND(leave_team, "leave team", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "TEAM:LEAVE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // leave_team // + + +//----------------------------------------------- +// 'join_team' +//----------------------------------------------- +NLMISC_COMMAND(join_team, "join the specified team", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "TEAM:JOIN"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // join_team // + + +//----------------------------------------------- +// 'join_team_proposal' +//----------------------------------------------- +NLMISC_COMMAND(join_team_proposal, "propose to current target to join the team", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "TEAM:JOIN_PROPOSAL"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // join_team_proposal // + +//----------------------------------------------- +// 'join_team_decline' +//----------------------------------------------- +NLMISC_COMMAND(join_team_decline, "decline a join team proposal", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "TEAM:JOIN_PROPOSAL_DECLINE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // join_team_decline // + +//----------------------------------------------- +// 'kick_teammate' +//----------------------------------------------- +NLMISC_COMMAND(kick_teammate, "kick someone from your team", "") +{ + // Create the message for the server to execute a phrase. + const string msgName = "TEAM:KICK"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // kick_teammate // + +//----------------------------------------------- +// 'cancel_current_sentence' +//----------------------------------------------- +NLMISC_COMMAND(cancel_current_sentence, "cancel the sentence being executed", "") +{ + // no parameter needed + + // Create the message for the server to cancel the phrase being executed + const string msgName = "SENTENCE:CANCEL_CURRENT"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("command : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // cancel_current_sentence // + + +//----------------------------------------------- +// 'cancel_all_sentences' +//----------------------------------------------- +NLMISC_COMMAND(cancel_all_sentences, "cancel all the sentences being executed", "") +{ + // no parameter needed + + // Create the message for the server to cancel the phrase being executed + const string msgName = "SENTENCE:CANCEL_ALL"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + NetMngr.push(out); + } + else + nlwarning("command : unknown message name : '%s'.", msgName.c_str()); + + return true; +} // cancel_all_sentences // + + +//----------------------------------------------- +// 'ignore' +//----------------------------------------------- +NLMISC_COMMAND(ignore, "add or remove a player from the ignore list", "") +{ + // Check parameters. + if(args.size() < 1) + { + return false; + } + + // send info + string player = args[0]; + ChatMngr.ignore( player ); + + return true; + +} // ignore // + + +/* +//----------------------------------------------- +// drop : +//----------------------------------------------- +NLMISC_COMMAND(drop,"drop an item to the ground","") +{ + if( args.size() < 1 ) + { + return false; + } + + uint32 id = atoi( args[0].c_str() ); + CEntityId itemId(RYZOMID::object,id); + + sint32 x = (sint32)UserEntity.pos().x * 1000; + sint32 y = (sint32)UserEntity.pos().y * 1000; + sint32 z = (sint32)UserEntity.pos().z * 1000; + + CBitMemStream bms; + string msgType = "ITEM:DROP"; + if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) + { + bms.serial( itemId ); + bms.serial( x ); + bms.serial( y ); + bms.serial( z ); + NetMngr.push( bms ); + nldebug(" sending 'ITEM:DROP' message to server"); + } + else + { + nlwarning(" unknown message name : ITEM:DROP"); + } + + return true; +}// drop // +*/ + + +////////// +// DEMO // + +class CDummyProgress : public IProgressCallback +{ + void progress (float value) {}; +}; + +#ifndef _LIMITED_COMMAND_ +//----------------------------------------------- +// teleport : +// Teleport the User somewhere else. +//----------------------------------------------- +void teleport(const CVectorD &pos) +{ + if(!ClientCfg.Local) + { + // Create the message for the server to teleport the character. + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("TP:WANTED", out)) + { + sint32 x = (sint32)(pos.x*1000.0); + sint32 y = (sint32)(pos.y*1000.0); + sint32 z = (sint32)(pos.z*1000.0); + out.serial( x ); + out.serial( y ); + out.serial( z ); + // Add the message to the send list. + NetMngr.push(out); + // send TELEPORT + nldebug("teleport: TELEPORT sent"); + } + else + nlwarning("teleport: unknown message name : 'TP:WANTED'."); + } + else + { + // Remove the selection. + UserEntity.selection(CLFECOMMON::INVALID_SLOT); + // Remove the target. + UserEntity.targetSlot(CLFECOMMON::INVALID_SLOT); + // Change the position of the entity and in Pacs. + UserEntity.pos(pos); + // Select the closest continent from the new position. + CDummyProgress dummy; + ContinentMngr.select(pos, dummy); + // Change the position of the entity and in Pacs. + UserEntity.pacsPos(pos); + } +}// teleport // + +//----------------------------------------------- +// 'pos' : Command To change the user position. +//----------------------------------------------- +NLMISC_COMMAND(pos, "Change the position of the user.", " OR 1 name of 'tp.teleport_list'. or a bot name") +{ + CVectorD newPos; + + // Named destination. + if(args.size() == 1) + { + string dest = args[0]; + newPos = CTeleport::getPos(NLMISC::strlwr(dest)); + if(newPos == CTeleport::Unknown) + { + //here we try to teleport to a bot destination + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("TP:BOT", out)) + { + string str = args[0]; + out.serial( str ); + nldebug("/pos: TP:BOT sent"); + NetMngr.push(out); + } + else + nlwarning("/pos: unknown message name : 'TP:BOT'."); + return true; + } + } + // Teleport to anywhere. + else if(args.size() == 2 || args.size() == 3) + { + newPos.x = atof(args[0].c_str()); + newPos.y = atof(args[1].c_str()); + if(args.size() == 3) + newPos.z = atof(args[2].c_str()); + else + newPos.z = 0.0; + } + // Bad argument number. + else + return false; + + // Teleport to the right destination. + teleport(newPos); + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'entity' : Create an entity on the user or just remove it if Form not valid. +//----------------------------------------------- +NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form not valid.", " ") +{ + // Check parameters. + if(args.size() != 2) + return false; + + // Try to create the sheet with the parameter as a string. + CSheetId sheetId; + if(!sheetId.build(args[1])) + { + // Try to create the sheet with the parameter as an int. + sheetId = atoi(args[1].c_str()); + if(sheetId == CSheetId::Unknown) + { + nlwarning("Command 'entity': '%s' is not a valid form.", args[1]); + return false; + } + } + + // The slot where the new entity will be. + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + + // Debug Infos + nldebug("Command 'entity' : AddNewEntity with form %s in the slot %d.", args[1].c_str(), slot); + // Remove the old entity. + EntitiesMngr.remove(slot, false); + // Create the new entity. + CEntityCL *entity = EntitiesMngr.create(slot, sheetId.asInt()); + if(entity) + { + // Update VP if Player + if(dynamic_cast(entity)) + { + SPropVisualA visualA; + visualA.PropertySubData.Sex = ClientCfg.Sex; + SPropVisualB visualB; + SPropVisualC visualC; + sint64 *prop = (sint64 *)&visualB; + IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); + prop = (sint64 *)&visualC; + IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); + prop = (sint64 *)&visualA; + IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); + EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); + } + + // Compute the position. + sint64 x = (sint64)((UserEntity.pos().x+UserEntity.front().x*2.0)*1000.0); + sint64 y = (sint64)((UserEntity.pos().y+UserEntity.front().y*2.0)*1000.0); + sint64 z = (sint64)((UserEntity.pos().z+UserEntity.front().z*2.0)*1000.0); + // Write the position in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); + // Update the position. + EntitiesMngr.updateVisualProperty(0, slot, 0); + // Set the direction + entity->front(UserEntity.front()); + entity->dir(UserEntity.front()); + + nlinfo("entity: slot: %d \"%s\", \"%f\", \"%f\", \"%f\", \"%f\", \"%f\", \"%f\" ",slot,args[1].c_str(), + (UserEntity.pos().x+UserEntity.front().x*2.0), (UserEntity.pos().y+UserEntity.front().y*2.0), (UserEntity.pos().z+UserEntity.front().z*2.0)); +// UserEntity.front().x, UserEntity.front().y, UserEntity.front().z ); + } + else + nldebug("command 'entity' : entity in slot %d removed.", slot); + + // Command well done. + return true; +}// entity // + + +//////////////////// +// DEBUG COMMANDS // +#include "string_manager_client.h" +#ifdef ENABLE_INCOMING_MSG_RECORDER +//----------------------------------------------- +// record +//----------------------------------------------- +NLMISC_COMMAND(record, "Start Recording", "name") +{ + // Check parameters. + if(args.size() != 1) + return false; + + // Warning when already recording. + if(NetMngr.isRecording()) + { + IM->displaySystemInfo(ucstring("Already Recording. Stop the current Record first")); + return true; + } + + // Save entities and DB. + dump(args[0]); + + // On/Off record. + if(!ClientCfg.Local) + NetMngr.setRecordingMode(true, args[0]+"_net.rec"); + return true; +}// record // + +//----------------------------------------------- +// replay +//----------------------------------------------- +NLMISC_COMMAND(replay, "replay", "name") +{ + // Check parameters. + if(args.size() != 1) + return false; + + // Load entities and DB. + loadDump(args[0]); + + // On/Off record. + if(ClientCfg.Local) + NetMngr.setReplayingMode(!NetMngr.isReplaying(), args[0]+"_net.rec"); + return true; +}// replay // + +//----------------------------------------------- +// stopRecord +//----------------------------------------------- +NLMISC_COMMAND(stopRecord, "Stop Recording", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + // On/Off record. + if(!ClientCfg.Local) + NetMngr.setRecordingMode(false); + return true; +}// stopRecord // +#endif // ENABLE_INCOMING_MSG_RECORDER + +//----------------------------------------------- +// 'dump' : command to create a file with the current state of the client. +//----------------------------------------------- +NLMISC_COMMAND(dump, "Command to create a file with the current state of the client.", " = default]") +{ + if(args.size() > 1) + return false; + + string dumpName; + if(args.size() == 1) + dumpName = args[0]; + else + dumpName = "default"; + + dump(dumpName); + return true; +}// dump // + +//----------------------------------------------- +// 'loadDump' : command to load a dump file. +//----------------------------------------------- +NLMISC_COMMAND(loadDump, "Ccommand to load a dump file.", "[ = default]") +{ + if(args.size() > 1) + return false; + + string dumpName; + if(args.size() == 1) + dumpName = args[0]; + else + dumpName = "default"; + + loadDump(dumpName); + return true; +}// loadDump // + + +//----------------------------------------------- +// 'watchEntity' : Choose the entity to watch. +//----------------------------------------------- +NLMISC_COMMAND(sheet2idx, "Return the index ", " ") +{ + if(args.size() != 2) + return false; + + string result; + NLMISC::CSheetId sheetId; + + if(sheetId.build(args[0])) + { + uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)atoi(args[1].c_str())); + result = NLMISC::toString("Index = %d", idx); + } + else + result = NLMISC::toString("sheet '%s' not valid.", args[0].c_str()); + + IM->displaySystemInfo(ucstring(result)); + nlinfo("'sheet2idx': %s", result.c_str()); + return true; +} + +//----------------------------------------------- +// 'watchEntity' : Choose the entity to watch. +//----------------------------------------------- +NLMISC_COMMAND(watchEntity, "Choose the entity to watch.", "") +{ + if(args.size() != 1) + return false; + + // Set the new debug entity slot. + WatchedEntitySlot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + return true; +}// watchEntity // + +//----------------------------------------------- +// 'dynstr' +//----------------------------------------------- +NLMISC_COMMAND(dynstr, "display a dyn string value", "") +{ + if (args.size() != 1) + return false; + + uint dynId = atoi(args[0].c_str()); + + ucstring result; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynId, result); + + CInterfaceManager::getInstance()->displaySystemInfo(result); + return true; +}// dynstr // + +NLMISC_COMMAND(serverstr, "display a server string value", "") +{ + if (args.size() != 1) + return false; + + uint dynId = atoi(args[0].c_str()); + + ucstring result; + STRING_MANAGER::CStringManagerClient::instance()->getString(dynId, result); + + CInterfaceManager::getInstance()->displaySystemInfo(result); + return true; +}// serverstr // + +//----------------------------------------------- +// 'verboseAnimSelection' : Enable/Disable the animation log for the current selection. +//----------------------------------------------- +NLMISC_COMMAND(verboseAnimSelection, "Enable/Disable the animation log for the current selection.", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + VerboseAnimSelection = !VerboseAnimSelection; + if(VerboseAnimSelection) + nlinfo("Enable VerboseAnimSelection"); + else + nlinfo("Disable VerboseAnimSelection"); + + return true; +}// verboseAnimSelection // + +//----------------------------------------------- +// 'verboseAnimUser' : Enable/Disable the animation log for the user. +//----------------------------------------------- +NLMISC_COMMAND(verboseAnimUser, "Enable/Disable the animation log for the user.", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + VerboseAnimUser = !VerboseAnimUser; + if(VerboseAnimUser) + nlinfo("Enable VerboseAnimUser"); + else + nlinfo("Disable VerboseAnimUser"); + + return true; +}// VerboseAnimUser // + +//----------------------------------------------- +// 'verboseDatabase' : Enable/Disable the log for the database. +//----------------------------------------------- +NLMISC_COMMAND(verboseDatabase, "Enable/Disable the log for the database.", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + VerboseDatabase = !VerboseDatabase; + if(VerboseDatabase) + nlinfo("Enable VerboseDatabase"); + else + nlinfo("Disable VerboseDatabase"); + + return true; +}// verboseDatabase // + +//----------------------------------------------- +// 'verboseVP' : Enable/Disable the visual properties log. +//----------------------------------------------- +NLMISC_COMMAND(verboseVP, "Enable/Disable the visual properties log.", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + VerboseVP = !VerboseVP; + if(VerboseVP) + nlinfo("Enable verboseVP"); + else + nlinfo("Disable verboseVP"); + + return true; +}// verboseVP // + + +//----------------------------------------------- +// verbosePropertiesLoggingMode +//----------------------------------------------- +NLMISC_COMMAND(verbosePropertiesLoggingMode, "Set logging mode", "") +{ + // Check parameters. + if(args.size() != 0) + return false; + + CNetworkConnection::LoggingMode = !CNetworkConnection::LoggingMode; + if(CNetworkConnection::LoggingMode) + nlinfo("Enable LoggingMode"); + else + nlinfo("Disable LoggingMode"); + + return true; +} + + +//----------------------------------------------- +// 'where' : display player position (on the server) +//----------------------------------------------- +NLMISC_COMMAND(where, "display player position (on the server)", " ") +{ + // Check parameters. + if(args.size() != 0) + return false; + + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:WHERE", out)) + NetMngr.push(out); + else + nlwarning("mainLoop : unknown message name DEBUG:WHERE"); + return true; +}// chat_mode // + +//----------------------------------------------- +// 'who' : Display all players currently in game +//----------------------------------------------- +NLMISC_COMMAND(who, "Display all players currently in game"," ") +{ + // Check parameters. + if(args.size() != 0) + return false; + + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:WHO", out)) + NetMngr.push(out); + else + nlwarning("mainLoop : unknown message name DEBUG:WHO"); + return true; +}// who // + +//----------------------------------------------- +// 'cmd' : Send a command to a server +//----------------------------------------------- +NLMISC_COMMAND(cmd, "Send a command to a server"," ") +{ + // Check parameters. + if(args.size() < 2) + return false; + + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:CMD", out)) + { + bool addentity = false; + string dest = args[0]; + string cmd = args[1]; + string arg; + for (uint i = 2; i < args.size(); i++) + { + arg += args[i] + " "; + } + out.serial(addentity); + out.serial(dest); + out.serial(cmd); + out.serial(arg); + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name DEBUG:CMD"); + return true; +}// cmd // + +//----------------------------------------------- +// 'cmd' : Send a command to a server +//----------------------------------------------- +NLMISC_COMMAND(cmde, "Send a command to a server with entityid"," ") +{ + // Check parameters. + if(args.size() < 2) + return false; + + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:CMD", out)) + { + bool addentity = true; + string dest = args[0]; + string cmd = args[1]; + string arg; + for (uint i = 2; i < args.size(); i++) + { + arg += args[i] + " "; + } + out.serial(addentity); + out.serial(dest); + out.serial(cmd); + out.serial(arg); + NetMngr.push(out); + } + else + nlwarning("mainLoop : unknown message name DEBUG:CMD"); + return true; +}// cmde // + +//----------------------------------------------- +// 'services' : Ask the server all services up. +//----------------------------------------------- +NLMISC_COMMAND(services, "Ask the server all services up.", "") +{ + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("DEBUG:SERVICES", out)) + { + // Add the message to the send list. + NetMngr.push(out); + // send TELEPORT + nlinfo("command 'services': 'DEBUG:SERVICES' sent."); + } + else + nlwarning("command 'services': unknown message named 'DEBUG:SERVICES'."); + + return true; +} + +//----------------------------------------------- +// 'mode' : Command To change the mode for an entity in a slot. +//----------------------------------------------- +NLMISC_COMMAND(mode, "Command To change the mode for an entity in a slot.", " ") +{ + // Check parameters. + if(args.size() != 2) + { + // Help + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 paramters :")); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the mode wanted for the entity, one of the following number :")); + for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i)))); + } + // Right parameters number + else + { + // Compute parameters + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + MBEHAV::EMode mod = (MBEHAV::EMode)atoi(args[1].c_str()); + + // Compute the position. + CEntityCL *entity = EntitiesMngr.entity(slot); + if(entity) + { + // Write the behaviour in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_MODE), mod); + // Update the behaviour. + entity->updateVisualProperty(NetMngr.getCurrentServerTick()+10, CLFECOMMON::PROPERTY_MODE); + } + // Invalid slot. + else + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot.")); + } + + // Command well done. + return true; +}// mode // + +//----------------------------------------------- +// 'behaviour' : Command To change the behaviour for an entity in a slot. +//----------------------------------------------- +NLMISC_COMMAND(behaviour, "Command To change the behaviour for an entity in a slot.", " [] []") +{ + // Check parameters. + if(args.size() < 2 || args.size() > 4) + { + // Help + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); + for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); + CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); + } + else + { + // COmpute parameters + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + MBEHAV::EBehaviour beh = (MBEHAV::EBehaviour)atoi(args[1].c_str()); + // Make the behaviour + MBEHAV::CBehaviour behaviour(beh); + // Get the Power + if(args.size() >= 3) + behaviour.Combat.AttackIntensity = atoi(args[2].c_str()); + if(args.size() >= 4) + behaviour.Combat.ImpactIntensity = atoi(args[3].c_str()); + + // Compute the position. + CEntityCL *entity = EntitiesMngr.entity(slot); + if(entity) + { + // Cast into an uint32. + uint32 b = behaviour; + // Write the behaviour in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_BEHAVIOUR), b); + // Update the behaviour. + entity->updateVisualProperty(NetMngr.getCurrentServerTick()+10, CLFECOMMON::PROPERTY_BEHAVIOUR); + } + else + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot.")); + } + + // Command well done. + return true; +}// behaviour // + +//----------------------------------------------- +// 'magic' : Command to cast a spell. +//----------------------------------------------- +NLMISC_COMMAND(magic, "Command to cast a spell.", "\n" +" : the one who cast the spell\n" +" : 0->GOOD 1->Bad 2->NEUTRAL\n" +" : 0->success 1->Fail 2->Fumble\n" +" : \n" +" : \n" +" : 0->not resisted, any other->resisted.\n") +{ + // Check parameters. + if(args.size() != 6) + { + // Help +// CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); +// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); +// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); +// for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); +// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); + } + else + { + // Compute parameters + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + // Magic Type (good bad neutral) + uint type = atoi(args[1].c_str())%3; + MBEHAV::EBehaviour behTmp = (MBEHAV::EBehaviour)(MBEHAV::CASTING_GOOD+type); + MBEHAV::CBehaviour castingBeh(behTmp); + // Result + MBEHAV::CBehaviour behaviour; + uint result = atoi(args[2].c_str())%3; + if (type==0) + behaviour.Behaviour = (MBEHAV::EBehaviour)(MBEHAV::END_CASTING_GOOD_SUCCESS + result); + else if(type==1) + behaviour.Behaviour = (MBEHAV::EBehaviour)(MBEHAV::END_CASTING_BAD_SUCCESS + result); + else + behaviour.Behaviour = (MBEHAV::EBehaviour)(MBEHAV::END_CASTING_NEUTRAL_SUCCESS + result); + // Spell Power + behaviour.Magic.SpellPower = atoi(args[3].c_str()); + // Impact Intensity + behaviour.Magic.ImpactIntensity = atoi(args[4].c_str()); + // Resist + behaviour.Magic.TargetResists = (atoi(args[5].c_str()) != 0); + // Get the entity + CEntityCL *entity = EntitiesMngr.entity(slot); + if(entity) + { + // Cast into an uint32. + uint32 b = castingBeh; + // Write the behaviour in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_BEHAVIOUR), b); + // Update the behaviour. + entity->updateVisualProperty(NetMngr.getCurrentServerTick()+10, CLFECOMMON::PROPERTY_BEHAVIOUR); + b = behaviour; + // Write the behaviour in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P" + toString(CLFECOMMON::PROPERTY_BEHAVIOUR), b); + // Update the behaviour. + entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); + } + else + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot.")); + } + + // Command well done. + return true; +}// magic // + + +//----------------------------------------------- +// 'target' : Set the target for an entity. Do not set the target slot to remove the target. +//----------------------------------------------- +NLMISC_COMMAND(target, "Set a target for an entity. Do not set the target slot to remove the target.", " []") +{ + CLFECOMMON::TCLEntityId targetSlot = CLFECOMMON::INVALID_SLOT; + + // Check parameters. + switch(args.size()) + { + // Set the target for the entity. + case 2: + targetSlot = (CLFECOMMON::TCLEntityId)atoi(args[1].c_str()); + + // Remove the target for the entity. + case 1: + { + uint entitySlot = (uint)atoi(args[0].c_str()); + CEntityCL *entity = EntitiesMngr.entity(entitySlot); + if(entity) + entity->targetSlot(targetSlot); + else + nlwarning("command 'target': there is no entity in the slot %d.", entitySlot); + } + break; + + // Bad command. + default: + return false; + } + + // Well done. + return true; +} + +//----------------------------------------------- +// 'particle' : Create a particle at the the user position +//----------------------------------------------- +NLMISC_COMMAND(particle, "Create a particule at the user position (play FireWorkA_with_sound.ps by default)", "[]") +{ + string fn; + + // Check parameters. + if(args.size() == 0) + { + fn = "FireWorkA_with_sound.ps"; + } + else if(args.size() == 1) + { + fn = args[0]; + } + else + return false; + + UInstance *fx = Scene->createInstance(fn); + + // not found + if(fx == NULL) + { + log.displayNL ("Can't create instance '%s'", fn.c_str()); + return false; + } + + fx->setPos(UserEntity.pos()); + fx->setClusterSystem(UserEntity.skeleton()->getClusterSystem()); + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'move' : Move an entity. +//----------------------------------------------- +NLMISC_COMMAND(move, "Move an entity.", "Form ID; Slot: [1-254]") +{ + // Check parameters. + if(args.size() != 1) + return false; + + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + + // Compute the position. + CEntityCL *entity = EntitiesMngr.entity(slot); + if(entity) + { + sint64 x = (sint64)((entity->pos().x+UserEntity.front().x*10.0)*1000.0); + sint64 y = (sint64)((entity->pos().y+UserEntity.front().y*10.0)*1000.0); + sint64 z = (sint64)((entity->pos().z+UserEntity.front().z*10.0)*1000.0); + // Write the position in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); + // Update the position. + EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+30, slot, 0); + + x = (sint64)((entity->pos().x)*1000.0); + y = (sint64)((entity->pos().y)*1000.0); + z = (sint64)((entity->pos().z)*1000.0); + // Write the position in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); + // Update the position. + EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+60, slot, 0); + } + else + nlwarning("command 'move' : there is no entity allocated in slot %d.", slot); + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'move_to' : Move an entity to another one. +//----------------------------------------------- +NLMISC_COMMAND(move_to, "Move an entity to another one.", ":[1-254], :[0-254] default 0") +{ + sint64 x, y, z; + + // Check parameters. + if(args.size() == 1) + { + x = (sint64)(UserEntity.pos().x*1000.0); + y = (sint64)(UserEntity.pos().y*1000.0); + z = (sint64)(UserEntity.pos().z*1000.0); + } + else if(args.size() == 2) + { + CLFECOMMON::TCLEntityId slotDest = (CLFECOMMON::TCLEntityId)atoi(args[1].c_str()); + // Compute the position. + CEntityCL *entity = EntitiesMngr.entity(slotDest); + if(entity) + { + x = (sint64)(entity->pos().x*1000.0); + y = (sint64)(entity->pos().y*1000.0); + z = (sint64)(entity->pos().z*1000.0); + } + else + { + // Command is correct but not all the parameters are valid. + nlwarning("command 'move_to' : there is no entity allocated for the dest in slot %d.", slotDest); + return true; + } + } + // Wrong number of parameters. + else + return false; + + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + // Write the position in the DB. + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P0", x); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P1", y); + IngameDbMngr.setProp("Entities:E" + toString(slot) + ":P2", z); + // Update the position. + EntitiesMngr.updateVisualProperty(NetMngr.getCurrentServerTick()+30, slot, 0); + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'setMode' : Set The Mode for an Entity without to add a stage for it. +//----------------------------------------------- +NLMISC_COMMAND(setMode, "Set The Mode for an Entity without to add a stage for it.", " ") +{ + // Check parameters. + if(args.size() != 2) + return false; + + // Get the Slot and the Mode. + CLFECOMMON::TCLEntityId slot = (CLFECOMMON::TCLEntityId)atoi(args[0].c_str()); + MBEHAV::EMode mod = (MBEHAV::EMode)atoi(args[1].c_str()); + + // Compute the position. + CEntityCL *entity = EntitiesMngr.entity(slot); + if(entity) + entity->mode(mod); + else + nlwarning("command 'setMode' : there is no entity allocated in slot '%d'.", slot); + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'logEntities' : Write the position and orientation af all entities in the vision in the file 'entities.txt'. +//----------------------------------------------- +NLMISC_COMMAND(logEntities, "Write the position and orientation af all entities in the vision in the file 'entities.txt'.", "") +{ + // Check parameters + if(args.size() != 0) + return false; + + // Log entities + EntitiesMngr.writeEntities(); + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'log' : Command to Add/Del Positive/Negative Filters for logs. +//----------------------------------------------- +NLMISC_COMMAND(log, "Add/Del Positive/Negative Filters for logs.", "Log System , Type , Filter ") +{ + // check args, if there s not the right number of parameter, return bad + if(args.size() < 2 || args.size() > 3) + return false; + + CLog *logSys; + // Debug log system. + if (string(args[0].c_str()) == "debug") + logSys = DebugLog; + // Info log system. + else if(string(args[0].c_str()) == "info") + logSys = InfoLog; + // Warning log system. + else if(string(args[0].c_str()) == "warning") + logSys = WarningLog; + // Assert log system. + else if(string(args[0].c_str()) == "assert") + logSys = AssertLog; + // Unknown Log System -> return false. + else + return false; + + // Add a positive filter. + if (string(args[1].c_str()) == "pos") + logSys->addPositiveFilter(args[2].c_str()); + // Add a negative filter. + else if(string(args[1].c_str()) == "neg") + logSys->addNegativeFilter(args[2].c_str()); + // Removes a filter by name (in both filters). + else if(string(args[1].c_str()) == "del") + logSys->removeFilter(args[2].c_str()); + // Reset both filters. + else if(string(args[1].c_str()) == "reset") + logSys->resetFilters(); + // Unknown Filter -> return false. + else + return false; + + // Command well done. + return true; +} + +//----------------------------------------------- +// 'db' : Command to change some variables in the database or to get it +//----------------------------------------------- +NLMISC_COMMAND(db, "Modify Database"," ") +{ + int size = args.size(); + if (size == 2) + { + // Convert the string into an sint64. + sint64 value = atoiInt64(args[1].c_str()); + // Set the property. + CInterfaceManager::getInstance()->getDbProp(args[0])->setValue64(value); + } + else if (size == 1) + { + sint64 prop = CInterfaceManager::getInstance()->getDbProp(args[0])->getValue64(); + string str = toString(prop); + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->displaySystemInfo(ucstring(str)); + nlinfo("%s", str.c_str()); + return true; + } + else + return false; + + return true; +}// db // + +//----------------------------------------------- +// 'exec' : Execute a scipt file +//----------------------------------------------- +extern CLog g_log; + +NLMISC_COMMAND(exec, "Execute a scipt file","") +{ + int size = args.size(); + if (size != 1) + return false; + + CIFile iFile; + + if (iFile.open(CPath::lookup(args[0], false))) + { + char line[512]; + char *buffer; + // Read line by line and execute each line + + + bool eof = false; + while (!eof) + { + buffer = &line[0]; + uint read = 0; + while (true) + { + if (read == 512 -1) + { + *buffer = '\0'; + break; + } + + try + { + // read one byte + iFile.serialBuffer ((uint8 *)buffer, 1); + } + catch (EFile &) + { + *buffer = '\0'; + eof = true; + break; + } + + if (*buffer == '\n') + { + *buffer = '\0'; + break; + } + + // skip '\r' char + if (*buffer != '\r') + { + buffer++; + read++; + } + } + if (strlen(line) > 0) + ICommand::execute(line, g_log); + if (iFile.eof()) + eof = true; + } + iFile.close(); + } + else + { + CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Cannot open file")); + } + + return true; +}// exec // + +//----------------------------------------------- +// 'vP' : Modify the Visual Property. +//----------------------------------------------- +NLMISC_COMMAND(vP, "Modify the Visual Property.", +"\n" +" of the entity to change.\n" +" the property to change :\n" +" 0->CHEST\n" +" 1->LEG\n" +" 2->ARM\n" +" 3->HEAD\n" +" 4->WEAPON_R\n" +" 5->WEAPON_L\n" +" 6->FEET\n" +" 7->HAND\n" +" 8->EYES\n" +" 9->SEX (0: Male, 1: Female)\n" +" for the property.\n") +{ + // Check parameters + if(args.size() != 3) + return false; + + // Get the database entry. + SPropVisualA vA; + SPropVisualB vB; + SPropVisualC vC; + uint slot = atoi(args[0].c_str()); + const string propNameA = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); + const string propNameB = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPB); + const string propNameC = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPC); + vA.PropertyA = CInterfaceManager::getInstance()->getDbProp(propNameA)->getValue64(); + vB.PropertyB = CInterfaceManager::getInstance()->getDbProp(propNameB)->getValue64(); + vC.PropertyC = CInterfaceManager::getInstance()->getDbProp(propNameC)->getValue64(); + // Get the visual item index + uint value = atoi(args[2].c_str()); + // Get the visual slot to change. + uint type = atoi(args[1].c_str()); + switch(type) + { + case 0: + vA.PropertySubData.JacketModel = value; + break; + case 1: + vA.PropertySubData.TrouserModel = value; + break; + case 2: + vA.PropertySubData.ArmModel = value; + break; + case 3: + vA.PropertySubData.HatModel = value; + break; + case 4: + vA.PropertySubData.WeaponRightHand = value; + break; + case 5: + vA.PropertySubData.WeaponLeftHand = value; + break; + case 6: + vB.PropertySubData.FeetModel = value; + break; + case 7: + vB.PropertySubData.HandsModel = value; + break; + case 8: + vC.PropertySubData.EyesColor = value; + break; + case 9: + vA.PropertySubData.Sex = value; + break; + + default: + nlwarning("command 'vP': type not valid."); + return false; + break; + } + + // Set the database. + CInterfaceManager::getInstance()->getDbProp(propNameA)->setValue64((sint64)vA.PropertyA); + CInterfaceManager::getInstance()->getDbProp(propNameB)->setValue64((sint64)vB.PropertyB); + CInterfaceManager::getInstance()->getDbProp(propNameC)->setValue64((sint64)vC.PropertyC); + // Force to update properties. + EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); + + // Done. + return true; +}// vP // + + +//----------------------------------------------- +// 'altLook' : Modify the Visual Property. +//----------------------------------------------- +NLMISC_COMMAND(altLook, "Modify the Alternative Look Property.", + "\n" + " of the entity to change.\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n") +{ + // Check parameters + if(args.size() != 8) + return false; + + // Get the database entry. + uint slot = atoi(args[0].c_str()); + const string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); + // Get the old value (not useful since we change the whole property). + SAltLookProp altLookProp; + altLookProp.Summary = CInterfaceManager::getInstance()->getDbProp(propName)->getValue64(); + altLookProp.Element.ColorTop = atoi(args[1].c_str()); + altLookProp.Element.ColorBot = atoi(args[2].c_str()); + altLookProp.Element.WeaponRightHand = atoi(args[3].c_str()); + altLookProp.Element.WeaponLeftHand = atoi(args[4].c_str()); + altLookProp.Element.Seed = atoi(args[5].c_str()); + altLookProp.Element.ColorHair = atoi(args[6].c_str()); + altLookProp.Element.Hat = atoi(args[7].c_str()); + + // Set the database. + CInterfaceManager::getInstance()->getDbProp(propName)->setValue64((sint64)altLookProp.Summary); + // Force to update properties. + EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); + + // Done. + return true; +}// altLook // + +//----------------------------------------------- +// 'color' : Command to color an entity. +//----------------------------------------------- +NLMISC_COMMAND(color, "Command to color an entity.", +"\n" +": whole number (if <0 slot will be the current selection)\n" +": whole number\n" +": whole number\n" +": whole number\n" +"[]: whole number\n" +" default=the whole body\n" +" 0=CHEST\n" +" 1=LEG\n" +" 2=HEAD\n" +" 3=ARMS\n" +" 4=HANDS\n" +" 5=FEET\n") +{ + // Check parameters. + if(args.size() != 4 && args.size() != 5) + return false; + + // Witch part to dye ? + sint part = -1; + if(args.size() == 5) + part = atoi(args[4].c_str()); + + // Get the entity slot to dye. + sint slotTmp = atoi(args[0].c_str()); + CLFECOMMON::TCLEntityId slot; + if(slotTmp >= 0) + slot = (CLFECOMMON::TCLEntityId)slotTmp; + else + slot = (CLFECOMMON::TCLEntityId)UserEntity.selection(); + + CEntityCL *entity = EntitiesMngr.entity(slot); + if(entity) + entity->changeColors(atoi(args[1].c_str()), atoi(args[2].c_str()), atoi(args[3].c_str()), part); + else + nlwarning("command 'changeColors': there is no entity allocated in slot '%d'.", slot); + + // Command well done. + return true; +}// color // +#endif // #ifndef _LIMITED_COMMAND_ + + +//----------------------------------------------- +// 'fire' : Command to launch the firework. +//----------------------------------------------- +NLMISC_COMMAND(fire, "launch the firework","") +{ + Firework->start(T1); + return true; +} + +//----------------------------------------------- +// 'save_int_cfg' : save the interface config file. +//----------------------------------------------- +NLMISC_COMMAND(save_int_cfg, "save the interface config file","") +{ + CInterfaceManager::getInstance()->saveConfig ("interface.cfg"); + return true; +} + + +//----------------------------------------------- +// 'harvest_deposit' +//----------------------------------------------- +NLMISC_COMMAND(harvest_deposit, "harvest a deposit", "") +{ + // no parameter needed + + // Create the message for the server + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("HARVEST:DEPOSIT", out)) + { + NetMngr.push(out); + + // open the interface + CInterfaceManager::getInstance()->getWindowFromId("ui:interface:harvest")->setActive(true); + } + else + nlwarning("command : unknown message name : 'HARVEST:DEPOSIT'."); + + return true; +} // harvest_deposit // + +//----------------------------------------------- +// 'training' +//----------------------------------------------- +NLMISC_COMMAND(training, "start a training action", "") +{ + // no parameter needed + + // Create the message for the server + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("TRAINING", out)) + { + NetMngr.push(out); + } + else + nlwarning("command : unknown message name : 'TRAINING'."); + + return true; +} // training // + +//----------------------------------------------- +// 'mount' : Set the entity to mount. +//----------------------------------------------- +NLMISC_COMMAND(mount, "Set the entity to mount."," []") +{ + CLFECOMMON::TCLEntityId slot; + CLFECOMMON::TCLEntityId mount = CLFECOMMON::INVALID_SLOT; + + switch(args.size()) + { + case 2: + mount = (CLFECOMMON::TCLEntityId) atoi(args[1].c_str()); + case 1: + slot = (CLFECOMMON::TCLEntityId) atoi(args[0].c_str()); + break; + + default: + return false; + break; + } + + // Set the database. + string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); + CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(mount); + // Force to update properties. + EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); + + // Command well done + return true; +}// mount // + +//----------------------------------------------- +// 'rider' : Set the rider. +//----------------------------------------------- +NLMISC_COMMAND(rider, "Set the rider."," []") +{ + CLFECOMMON::TCLEntityId slot; + CLFECOMMON::TCLEntityId rider = CLFECOMMON::INVALID_SLOT; + + switch(args.size()) + { + case 2: + rider = (CLFECOMMON::TCLEntityId) atoi(args[1].c_str()); + case 1: + slot = (CLFECOMMON::TCLEntityId) atoi(args[0].c_str()); + break; + + default: + return false; + break; + } + + // Set the database. + string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); + CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(rider); + // Force to update properties. + EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); + + // Command well done + return true; +}// rider // + + + +#ifndef _LIMITED_COMMAND_ +#ifdef _CMD_CHEAT_ON_ +//////////////////// +// CHEAT COMMANDS // + +NLMISC_COMMAND(learn_all, "learn all bricks", "all magic combat") +{ + // Check parameters. + if(args.size() > 1) + return false; + uint type = 0; + if(args.size() == 1) + { + if (args[0] == "magic" || args[0] == "1") + type = 1; + if (args[0] == "combat" || args[0] == "2") + type = 2; + } + char buf[100]; + if (ClientCfg.Local) + { + CBrickManager * pBM = CBrickManager::getInstance(); + uint i = 0; + for (; i < pBM->getNumberOfFamily(); i++ ) + { + sint64 flag = 0; + if ( pBM->getFamilySize(i) ) + { + CBrickSheet *brick= pBM->getBrick(pBM->getBrickSheet(i, 0)); + if(brick) + { + if ( type == 0 || (brick->BrickType == BRICK_TYPE::COMBAT && type == 2) || (brick->BrickType == BRICK_TYPE::MAGIC && type == 1) ) + { + for (uint j = 0; j < pBM->getFamilySize(i);j++) + { + flag |= (sint64)1 << (sint64)j; + } + sprintf(buf,"SERVER:BRICK_FAMILY:%d:BRICKS",i); + CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(buf); + node->setValue64(flag); + } + } + } + } + //set all career to 25 + for (i = 0; i < ROLES::role_unknown; i++ ) + { + string role = string("SERVER:CHARACTER_INFO:CAREER")+toString(3); + string prop = role +string(":LEVEL"); + CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(prop); + node->setValue64(25); + for (uint j = 0; j < 8; j++ ) + { + prop = role + string(":JOB") + toString(j) + string(":LEVEL"); + node= CInterfaceManager::getInstance()->getDbProp(prop); + node->setValue64(25); + } + } + // Learn all Faber Plans. For all database entries + uint faberPlanMId= 0; + while(true) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CCDBNodeLeaf *leaf= pIM->getDbProp("SERVER:FABER_PLANS:"+toString(faberPlanMId)+":KNOWN", false); + if(!leaf) + break; + leaf->setValue64(0xFFFFFFFFFFFFFFFF); + faberPlanMId++; + } + } + else + { + // Create the message for the server to learn all bricks + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:LEARN_ALL_BRICKS", out)) + { + // Add the message to the send list. + NetMngr.push(out); + // send TELEPORT + nlinfo("command 'learn_all': learn all bricks Asked."); + } + else + nlwarning("command 'learn_all': unknown message named 'CHEAT:LEARN_ALL_BRICKS'."); + } + return true; + +} // learn_all // + + +NLMISC_COMMAND(learnAllFaberPlans, "learn all faber plans", "") +{ + if (ClientCfg.Local) + { + // Learn all Faber Plans. For all database entries + uint faberPlanMId= 0; + while(true) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CCDBNodeLeaf *leaf= pIM->getDbProp("SERVER:FABER_PLANS:"+toString(faberPlanMId)+":KNOWN", false); + if(!leaf) + break; + leaf->setValue64(0xFFFFFFFFFFFFFFFF); + faberPlanMId++; + } + } + else + { + // Create the message for the server to learn all bricks + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:LEARN_ALL_FABER_PLANS", out)) + { + // Add the message to the send list. + NetMngr.push(out); + // send TELEPORT + nlinfo("command 'learnAllFaberPlans': learn all faber plans Asked."); + } + else + nlwarning("command 'learnAllFaberPlans': unknown message named 'CHEAT:LEARN_ALL_FABER_PLANS'."); + } + return true; +} // learnAllFaberPlans // + +//----------------------------------------------- +// 'god' : To be invulnerable. +//----------------------------------------------- +NLMISC_COMMAND(god, "To be invulnerable","") +{ + // Check parameters. + if(args.size() != 0) + return false; + + // Create the message for the server to teleport the character. + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:GOD", out)) + { + // Add the message to the send list. + NetMngr.push(out); + // send TELEPORT + nlinfo("command 'god': God Mode Asked."); + } + else + nlwarning("command 'god': unknown message named 'CHEAT:GOD'."); + + // Done. + return true; +}// god // + +//----------------------------------------------- +// 'createItem' : Create an item in the hand of the user. +//----------------------------------------------- +NLMISC_COMMAND(createItem, "Create an item in the hand of the user."," [] []") +{ + CSheetId sheetId; + uint16 quantity = 1; + uint16 quality = 1; + + // Check parameters. + switch(args.size()) + { + case 3: + quality = atoi(args[2].c_str()); + + case 2: + quantity = atoi(args[1].c_str()); + + case 1: + // Try to create the sheet with the parameter as a string. + if(!sheetId.build(args[0])) + { + // Try to create the sheet with the parameter as an int. + sheetId = atoi(args[0].c_str()); + } + break; + + // Bad number of parameters. + default: + nlwarning("Command 'createItem': invalid number of parameter."); + return false; + } + + // Check Sheet Id. + if(sheetId == CSheetId::Unknown) + { + nlwarning("Command 'createItem': '%s' is not a valid form.", args[0].c_str()); + return false; + } + + // Create the message for the server to teleport the character. + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:CREATE_ITEM_IN_BAG", out)) + { + uint32 sheet = sheetId.asInt(); + out.serial(sheet); + out.serial(quantity); + out.serial(quality); + // Add the message to the send list. + NetMngr.push(out); + // send TELEPORT + nlinfo("Command 'createItem': CREATE_ITEM_IN_BAG sent"); + } + else + nlwarning("Command 'createItem': unknown message named 'CHEAT:CREATE_ITEM_IN_BAG'."); + + // Command well done. + return true; +}// createItem // + +//----------------------------------------------- +// 'xp' : To gain XP in a given Skill. +//----------------------------------------------- +NLMISC_COMMAND(xp, "To gain XP in a given Skill."," ") +{ + // Check parameters. + if(args.size() != 2) + return false; + + // Create the message for the server to teleport the character. + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:XP", out)) + { + uint32 xp = atoi(args[1].c_str()); + string skill = args[0]; + out.serial( skill ); + out.serial(xp); + // Add the message to the send list. + NetMngr.push(out); + // send CHEAT:XP + nlinfo("command 'xp': CHEAT:XP pushed."); + } + else + nlwarning("command 'xp': unknown message named 'CHEAT:XP'."); + + // Done. + return true; +}// xp // + +//----------------------------------------------- +// 'money' : To earn Money. +// \todo +//----------------------------------------------- +NLMISC_COMMAND(money, "To earn Money."," [] [] []") +{ + sint32 a = 0; + sint32 b = 0; + sint32 c = 0; + sint32 d = 0; + + // Check parameters. + switch(args.size()) + { + case 4: + d = atoi(args[3].c_str()); + case 3: + c = atoi(args[2].c_str()); + case 2: + b = atoi(args[1].c_str()); + case 1: + a = atoi(args[0].c_str()); + break; + default: + return false; + } + + // Create the message for the server to teleport the character. + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream("CHEAT:MONEY", out)) + { + out.serial(a); + out.serial(b); + out.serial(c); + out.serial(d); + // Add the message to the send list. + NetMngr.push(out); + // send CHEAT:MONEY + nlinfo("command 'money': CHEAT:MONEY pushed."); + } + else + nlwarning("command 'money': unknown message named 'CHEAT:MONEY'."); + + // Done. + return true; +}// money // + +//----------------------------------------------- +// 'setTime' : To set Ryzom time on server. +//----------------------------------------------- +NLMISC_COMMAND(setTime, "To set Ryzom time on server."," + + + Language: + Sprache : + Create shortcuts: Erstelle VerknĂźpfungen: - + Desktop Desktop - + Start Menu Start-MenĂź diff --git a/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_es.ts b/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_es.ts index 493fbc7c9..d9ccd35d0 100644 --- a/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_es.ts +++ b/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_es.ts @@ -635,16 +635,21 @@ Just press Continue button and follow the different steps until everything is do + Language: + + + + Create shortcuts: - + Desktop - + Start Menu diff --git a/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_fr.ts b/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_fr.ts index b2499b8b5..906c22aab 100644 --- a/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_fr.ts +++ b/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_fr.ts @@ -841,16 +841,21 @@ Vous n'avez qu'Ă  cliquer sur Suivant et suivre les diffĂŠrentes ĂŠtap + Language: + Langage : + + + Create shortcuts: CrĂŠer les raccourcis : - + Desktop Bureau - + Start Menu Menu DĂŠmarrer diff --git a/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_ru.ts b/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_ru.ts index 88f2dccfb..4c9b0465c 100644 --- a/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_ru.ts +++ b/code/ryzom/tools/client/ryzom_installer/translations/ryzom_installer_ru.ts @@ -807,16 +807,21 @@ Just press Continue button and follow the different steps until everything is do + Language: + Язык: + + + Create shortcuts: Создать ярлыки: - + Desktop Рабочий стол - + Start Menu меню Пуск diff --git a/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui b/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui index 6f6cc7de8..209ab6a76 100644 --- a/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui +++ b/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 583 - 329 + 631 + 356 @@ -202,13 +202,20 @@ + + + Language: + + + + Create shortcuts: - + @@ -226,6 +233,35 @@ + + + + + English + + + + + Francais + + + + + Deutsch + + + + + EspaĂąol + + + + + Russian (РУССКИЙ) + + + + @@ -250,10 +286,11 @@ serverComboBox executableBrowseButton argumentsEdit - commentsEdit directoryButton + langComboBox desktopShortcutCheckBox menuShortcutCheckBox + commentsEdit diff --git a/code/ryzom/tools/client/ryzom_recover/ryzom_recover.cpp b/code/ryzom/tools/client/ryzom_recover/ryzom_recover.cpp new file mode 100644 index 000000000..66b40986e --- /dev/null +++ b/code/ryzom/tools/client/ryzom_recover/ryzom_recover.cpp @@ -0,0 +1,729 @@ +/** \file ryzom_recover.cpp + * App to setup minimal Ryzom context + * + * $Id: ryzom_recover.cpp,v 1.15 2007/06/07 13:34:25 boucher Exp $ + */ + +/* ---------------------------------------------------------- + * + * Ryzom Recover + * + * This application loads/restores minimal application set to connect + * to Ryzom and play/apply patches. + * + * Startup URIs to recover files are hardcoded (see const char* BaseURI[]). + * First it connects to provided URIs and tries to download a file called + * 'dir.gz' (see variable DirFilename). + * + * file 'dir.gz' has possibly the following forms: + * + * ----8<------------8<------------8<-------- + * RECOV + * client.cfg.gz|client.cfg.gz + * client_default.cfg.gz|client_default.cfg.gz + * launch.bat.gz|launch.bat.gz + * nel_launcher.cfg.gz|nel_launcher.cfg.gz + * nel_launcher.exe.gz|nel_launcher.exe.gz + * VERSION.gz|VERSION.gz + * ----8<------------8<------------8<-------- + * + * or for the newest version (which provided newer and more up to date URIs to + * download files from): + * + * ----8<------------8<------------8<-------- + * RECOV2 + * ftp://anonymous:password@ftprecover.ryzom.org/recover4/ + * http://ryzomrecover.dyndns.org/recover4/ + * http://recover.ryzom.com/recover4 + * FILELIST + * client.cfg.gz|client.cfg.gz + * client_default.cfg.gz|client_default.cfg.gz + * launch.bat.gz|launch.bat.gz + * nel_launcher.cfg.gz|nel_launcher.cfg.gz + * nel_launcher.exe.gz|nel_launcher.exe.gz + * VERSION.gz|VERSION.gz + * ----8<------------8<------------8<-------- + * + * Listed files are then downloaded from base URIs (or preferably from extended URIs + * if RECOV2 specified). It attempts to download from first URI to last until it found one. + * If all fail, it loops until success or timeout (see DownloadTimeout). When all servers + * are not reachable, it wait randomly some seconds (see MinFailureWait and MaxFailureWait) + * + * ---------------------------------------------------------- */ + + + +// +// Includes +// + +#include "nel/misc/types_nl.h" + +#include +#include +#include +#include +#include +#include +//#include +//#include +#include + +#undef min +#undef max + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + + +// +// Namespaces +// + +using namespace std; +using namespace NLMISC; +using namespace NLNET; + + +// +// Variables +// + +string currentFile; + +string DirFilename = "dir.gz"; + +string NameOfThisApplication; + +// These paths are for the open beta +/*const char*BaseURI[] = { // don't forget the final / + //"ftp://login:password@server.domain.com/", // ftp supported in libcurl + "http://213.208.119.189/recover/", + "http://213.208.119.190/recover/", + "http://ryzomrecover.dyndns.org/recover/", +};*/ + +// These paths are for the *gold* version +const char*BaseURI[] = { // don't forget the final / + "http://213.208.119.221/recover4/", // rspatch + "http://213.208.119.189/recover4/", // rsweb + "http://recover.ryzom.com/recover4/", // dns link + "http://recover.ryzom.com:43434/recover4/", // dns link + other port + "ftp://anonymous:recover@recover.ryzom.com/recover4/", // ftp dns link + "ftp://anonymous:recover@recover.ryzom.com:41414/recover4/", // ftp dns link + other port +}; + +// These paths are for the test version +/*const char*BaseURI[] = { // don't forget the final / + "http://213.208.119.221/test4/", // rspatch + "http://213.208.119.189/test4/", // rsweb + "http://recover.ryzom.com/test4/", // dns link +};* + +/** + * Download Timeout (in seconds) + * Checked when all downloading sources have failed to be reached + */ +const uint DownloadTimeout = 600; + +/** + * Time to wait between each attempt to download from sources. + */ +const uint MinFailureWait = 10; +const uint MaxFailureWait = 20; + +/** + * Extended URIs, based on BaseURI plus those downloaded from 'dir.gz' if RECOV2 present + */ +vector ExtURI; + + +// Don't forget the blank character at the end +const string ApplCouldNot = "The application could not "; +const string Explain1Download = ApplCouldNot + "download a file. "; +const string Explain1OpenRead = ApplCouldNot + "decompress a file. "; +const string Explain1OpenWrite = ApplCouldNot + "create a file. "; +const string Explain1MkDir = ApplCouldNot + "create a folder. "; +const string Explain1Decompress = ApplCouldNot + "decompress a file. "; +const string Explain1Access = ApplCouldNot + "get read/write access to a file. "; +const string Explain1Delete = ApplCouldNot + "delete a file. "; +const string Explain1InvalidContent = ApplCouldNot + "download a valid file list. "; +const string Explain1Internal = "An internal error occured. "; +const string Explain2Account = "If you use multiple Windows user accounts, you may have to log in with an administrator account, or with the same account that was used to install The Saga Of Ryzom. "; +const string Explain2ProgramLocking = "Please close any other program that could be using the file. "; +const string Explain2DiskSpace = "Please make sure you have sufficient disk space. "; +const string Explain2Network = "Please make sure your network settings are properly configured. If you have a firewall, you may have to configure it to accept an outgoing connection. "; + +enum TErrorStatus { + ESRecoverableAtOnce, // ask to retry + ESRecoverableLater, // ask to run again + ESUnrecoverable // ask to contact support +}; + +class ERestartApplication : public NLMISC::Exception {}; + +// +// Functions +// + +/* + * Display a user-friendly error message, suggest to send a nlerror report, then stop the application. + */ +void userFriendlyError( const string& explanation, bool hasDirectionsInExplanation, TErrorStatus errorStatus, const string& techReason, const string& later="" ) +{ + nlwarning( "ERROR: %s %s %u", explanation.c_str(), techReason.c_str(), (uint)errorStatus ); + + string text = explanation; + if ( hasDirectionsInExplanation ) + text += "\r\n\nThen "; + else + text += "\r\n\nPlease "; + UINT mbButtons; + + // Display message(s) boxe(s): + // + // Recoverable at once Recoverable later Unrecoverable + // | | | + // v v v + // Retry / Cancel --> Directions to run again or contact support --> OK + // | | + // v v + // Restart application NeL error message box + + // Ask to retry, if not done too many times + if ( errorStatus == ESRecoverableAtOnce ) + { + static uint nbRetries = 0; + ++nbRetries; + if ( nbRetries < 4 ) + { + text += "click Retry to restart the application now.\r\n"; + mbButtons = MB_RETRYCANCEL; + } + else + errorStatus = ESRecoverableLater; + } + + int clicked; + do + { + // Ask to restart later and/or to contact support + if ( errorStatus != ESRecoverableAtOnce ) + { + switch ( errorStatus ) + { + case ESRecoverableLater: + text += "run this application again" + later + ", by executing " + NameOfThisApplication + "\r\n\n"; + text += "If running several times this application does not resolve the problem, please "; + break; + default: // ARContactSupport + break; + } + text += "contact technical support at http://atys.ryzom.com/?page=support\r\n\n"; + mbButtons = MB_OK; + } + + // Present the next NeL Error message box + if ( mbButtons == MB_OK ) + text += "Now you'll see the detailed technical reason of the error. You will have the possibility to send a report to Nevrax.\r\n"; + + // Display the message box (ansi mode, no unicode string) + clicked = ::MessageBox( NULL, text.c_str(), "Ryzom Recover Application: Error", mbButtons | MB_ICONINFORMATION | MB_SETFOREGROUND ); + switch ( clicked ) + { + case IDRETRY: + throw ERestartApplication(); + break; + case IDCANCEL: + text = "If you want to retry later, "; + errorStatus = ESRecoverableLater; + break; + default: // IDOK + nlerror( techReason.c_str() ); + } + } + while ( clicked != IDOK ); + + // Do not let the user 'ignore' the error + printf("\n\nRyzom Recover failed. "); + exit( 1 ); +} + + +void setRWAccess (const string &filename) +{ + nlinfo("setRWAccess to '%s'", filename.c_str()); + + if (!NLMISC::CFile::setRWAccess(filename)) + { + userFriendlyError( Explain1Access + Explain2Account, true, ESRecoverableLater, + toString("Can't have read/write access to '%s' file : code=%d %s (error code 18)", filename.c_str(), errno, strerror(errno)) ); + } +} + +string deleteFile (const string &filename, bool failSilently=false) +{ + nlinfo("delete file '%s'", filename.c_str()); + + if (!NLMISC::CFile::deleteFile(filename)) + { + string str = toString("Can't delete '%s' file : code=%d %s (error code 19)", filename.c_str(), errno, strerror(errno)); + if ( ! failSilently ) + userFriendlyError( Explain1Delete + Explain2ProgramLocking + Explain2Account, true, + ESRecoverableAtOnce, str.c_str() ); + return str; + } + return ""; +} + +void decompressFile (const string &filename) +{ + nlinfo("Decompressing %s...", NLMISC::CFile::getFilename(filename).c_str ()); + + nlinfo("Calling gzopen('%s','rb')", filename.c_str()); + gzFile gz = gzopen (filename.c_str (), "rb"); + if (gz == 0) + { + string err = toString("Can't open compressed file '%s' : ", filename.c_str()); + if(errno == 0) + { + // gzerror + int gzerrno; + const char *gzerr = gzerror (gz, &gzerrno); + err += toString("code=%d %s", gzerrno, gzerr); + } + else + { + err += toString("code=%d %s", errno, strerror (errno)); + } + err += " (error code 31)"; + deleteFile (filename, true); + userFriendlyError( Explain1OpenRead, false, ESUnrecoverable, err.c_str() ); + } + + string dest = filename.substr(0, filename.size ()-3); + setRWAccess(dest); + nlinfo("Calling fopen('%s','wb')", dest.c_str()); + FILE *fp = fopen (dest.c_str(), "wb"); + if (fp == 0) + { + string err = toString("Can't open file '%s' : code=%d %s, (error code 32)", dest.c_str(), errno, strerror(errno)); + + gzclose(gz); + deleteFile (filename, true); + userFriendlyError( Explain1Decompress + Explain2DiskSpace + Explain2Account, true, ESRecoverableAtOnce, err.c_str() ); + } + + nlinfo("Entering the while loop decompression"); + + uint32 currentSize = 0; + uint8 buffer[10000]; + while (!gzeof(gz)) + { + nlinfo("Calling gzread"); + int res = gzread (gz, buffer, 10000); + nlinfo("gzread returns %d", res); + if (res == -1) + { + int gzerrno; + const char *gzerr = gzerror (gz, &gzerrno); + gzclose(gz); + fclose(fp); + //deleteFile (filename); + userFriendlyError( Explain1Decompress, false, ESUnrecoverable, + toString("Can't read compressed file '%s' (after %d bytes) : code=%d %s, (error code 33)", filename.c_str(), currentSize, gzerrno, gzerr) ); + } + + currentSize += res; + + nlinfo("Calling fwrite for %d bytes", res); + int res2 = fwrite (buffer, 1, res, fp); + nlinfo("fwrite returns %d", res2); + if (res2 != res) + { + string err = toString("Can't write file '%s' : code=%d %s (error code 34)", dest.c_str(), errno, strerror(errno)); + + gzclose(gz); + fclose(fp); + deleteFile (filename, true); + userFriendlyError( Explain1Decompress + Explain2DiskSpace + Explain2Account, true, ESRecoverableAtOnce, err.c_str() ); + } + } + + nlinfo("Exiting the while loop decompression"); + + nlinfo("Calling gzclose"); + gzclose(gz); + nlinfo("Calling fclose"); + fclose(fp); + deleteFile(filename, true); + + nlinfo("Exiting the decompressing file"); +} + +// source is an uri, dest is a full path +bool downloadFileWithCurl(const string &source, const string &dest) +{ + nlinfo("downloadFileWithCurl file src '%s' dst '%s'", source.c_str(), dest.c_str()); + + // delete the file if already exists + if(CFile::fileExists(dest)) + deleteFile(dest); + + CURL *curl; + CURLcode res; + + nlinfo("Getting %s", NLMISC::CFile::getFilename (source).c_str ()); + currentFile = NLMISC::CFile::getFilename (source); + + // create the local file + setRWAccess(dest); + FILE *fp = fopen (dest.c_str(), "wb"); + if(!fp) + { + userFriendlyError( Explain1OpenWrite + Explain2ProgramLocking + Explain2DiskSpace + Explain2Account, true, ESRecoverableAtOnce, + toString("Can't open file '%s' for writing: code=%d %s (error code 37)", dest.c_str (), errno, strerror(errno)) ); + } + + curl_global_init(CURL_GLOBAL_ALL); + curl = curl_easy_init(); + if(!curl) + { + userFriendlyError( Explain1Internal, false, ESUnrecoverable, "curl init failed" ); + } + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE); + curl_easy_setopt(curl, CURLOPT_URL, source.c_str()); + curl_easy_setopt(curl, CURLOPT_FILE, fp); + + res = curl_easy_perform(curl); + + long r; + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &r); + + curl_easy_cleanup(curl); + + fclose(fp); + curl_global_cleanup(); + + currentFile = ""; + + if(CURLE_FTP_COULDNT_RETR_FILE == res) + { + // file not found, delete local file + NLMISC::CFile::deleteFile(dest.c_str()); + nlwarning("curl download failed: (ec %d %d)", res, r); + return false; + } + + if(CURLE_WRITE_ERROR == res) + { + userFriendlyError( Explain1Decompress + Explain2DiskSpace, true, ESRecoverableAtOnce, + toString("Curl can't write '%s'", dest.c_str()) ); + } + + if(CURLE_OK != res) + { + NLMISC::CFile::deleteFile(dest.c_str()); + nlwarning("curl download failed: (ec %d %d)", res, r); + return false; + } + + if(r == 404) + { + // file not found, delete it + NLMISC::CFile::deleteFile(dest.c_str()); + nlwarning("curl download failed because url '%s' it not found: (ec %d %d)", source.c_str(), res, r); + return false; + } + + if(r < 200 || r >= 300) + { + // file not found, delete it + NLMISC::CFile::deleteFile(dest.c_str()); + nlwarning("return code is not in 200 range OK: (ec %d %d)", res, r); + return false; + } + return true; +} + + +/* + * Download a file from the last valid URI + */ +uint32 LastURINumber = 0; + +void download(const string &rawsrc, const string &dest) +{ + nlinfo("Downloading file rawsrc '%s' dst '%s'", rawsrc.c_str(), dest.c_str()); + + TTime start = CTime::getLocalTime(); + TTime timeout = start + DownloadTimeout*1000; + + srand((uint32)start); + + // try to download file until timeout + while (CTime::getLocalTime() < timeout) + { + uint32 NbURI = ExtURI.size(); + for (uint i = 0; i < NbURI; i++) + { + // clamp to table + LastURINumber = LastURINumber % NbURI; + + if (downloadFileWithCurl(ExtURI[LastURINumber]+rawsrc, dest)) + { + nlinfo("Successfully downloaded file '%s' from '%s'", rawsrc.c_str(), ExtURI[LastURINumber].c_str()); + return; + } + + // download failed, try with the next one + ++LastURINumber; + } + + // download failed on all sources, retry till timeout expires + // wait some random seconds to avoid flooding servers + uint wait = MinFailureWait + (uint)frand(MaxFailureWait-MinFailureWait); + TTime lock = CTime::getLocalTime(); + while (CTime::getLocalTime() - lock < wait*1000) + nlSleep(100); + } + + // no uri works, can't do anything + userFriendlyError( Explain1Download + Explain2Network, true, ESRecoverableAtOnce, + toString("No URI can retrieve the file '%s'", rawsrc.c_str()) ); +} + + + +/* + * Append Base URIs in ExtURI list + */ +void appendBaseURIsToExtURIs() +{ + uint32 NbURI = sizeof(BaseURI)/sizeof(BaseURI[0]); + for (uint i=0; iremoveDisplayer("DEFAULT_SD"); + InfoLog->removeDisplayer("DEFAULT_SD"); + WarningLog->removeDisplayer("DEFAULT_SD"); + AssertLog->removeDisplayer("DEFAULT_SD"); + ErrorLog->removeDisplayer("DEFAULT_SD"); + + NameOfThisApplication = argv[0]; + + // get the file that contains the list of files to download + + // first time, init URIs first base URIs + + gzFile gz = 0; + bool mustRestart = false; + do + { + try + { + ExtURI.clear(); + appendBaseURIsToExtURIs(); + + bool mustReDownloadNewDir = false; + do + { + if ( gz != 0 ) + { + gzclose(gz); + gz = 0; + } + download(DirFilename, DirFilename); + + gz = gzopen (DirFilename.c_str (), "rb"); + if (gz == 0) + { + int gzerrno; + const char *gzerr = gzerror (gz, &gzerrno); + userFriendlyError( Explain1OpenRead, false, ESUnrecoverable, + toString("Can't open file '%s': code=%d %s (error code 24)", DirFilename.c_str(), gzerrno, gzerr) ); + } + + char buffer[2000]; + if (gzgets (gz, buffer, 2000) == 0) + { + int gzerrno; + const char *gzerr = gzerror (gz, &gzerrno); + userFriendlyError( Explain1Decompress, false, ESUnrecoverable, + toString("Can't read header of'%s' : code=%d %s (error code 25)", DirFilename.c_str(), gzerrno, gzerr) ); + } + + // check the header file + if (string(buffer) == "RECOV\n") + { + /* + * Nothing to do, no new URIs provided + */ + nlinfo("Identified recover scheme 1 in %s", DirFilename.c_str()); + } + else if (string(buffer) == "RECOV2\n") + { + /* + * Read URI list till we find "FILELIST" token + * then proceed normally (read file list) + */ + nlinfo("Identified recover scheme 2 in %s, retrieving latest URI", DirFilename.c_str()); + + // reset URIs + ExtURI.clear(); + LastURINumber = 0; + + do + { + // get next uri + if (gzgets (gz, buffer, 2000) == 0) + { + int gzerrno; + const char *gzerr = gzerror (gz, &gzerrno); + userFriendlyError( Explain1Decompress, false, ESUnrecoverable, + toString("Can't read '%s' : code=%d %s (error code 27)", DirFilename.c_str(), gzerrno, gzerr) ); + } + + // is it end of list? + if (string(buffer) == "FILELIST\n") + break; + + // remove if \n if necessary + if(strlen(buffer)>0 && buffer[strlen(buffer)-1] == '\n') + buffer[strlen(buffer)-1] = '\0'; + + ExtURI.push_back(buffer); + } + while (!gzeof(gz)); + + // append to extURI list + appendBaseURIsToExtURIs(); + } + else + { + gzclose(gz); + deleteFile(DirFilename, true); + ++LastURINumber; + if ( LastURINumber >= ExtURI.size() ) + { + userFriendlyError( Explain1InvalidContent, false, ESRecoverableLater, + toString("%s has not a valid content '%s' : code=8888 (error code 26)", DirFilename.c_str(), buffer), + " later" ); + } + mustReDownloadNewDir = true; + continue; + } + + while (!gzeof(gz)) + { + // get a line + if (gzgets (gz, buffer, 2000) == 0) + { + int gzerrno; + const char *gzerr = gzerror (gz, &gzerrno); + userFriendlyError( Explain1Decompress, false, ESUnrecoverable, + toString("Can't read '%s' : code=%d %s (error code 27)", DirFilename.c_str(), gzerrno, gzerr) ); + } + + // remove if \n if necessary + if(strlen(buffer)>0 && buffer[strlen(buffer)-1] == '\n') + buffer[strlen(buffer)-1] = '\0'; + + // explode the string into | sep + string b = buffer; + vector res; + explode(b, std::string("|"), res); + + // error if doesn't contain 2 fields + if(res.size() != 2) + { + gzclose(gz); + gz=0; + deleteFile(DirFilename, true); + ++LastURINumber; + if ( LastURINumber >= ExtURI.size() ) + { + userFriendlyError( Explain1InvalidContent, false, ESRecoverableLater, toString("bad entry '%s'", b.c_str()) ); + } + mustReDownloadNewDir = true; // if RECOV2, will search the dir in the new set of URIs, but skips the first one! + break; + } + + // create the destination directory if necessary + string path = CFile::getPath(res[1]); + if( (!path.empty()) && (!CFile::isExists(path)) ) + { + if ( ! CFile::createDirectory(path) ) + userFriendlyError( Explain1MkDir + Explain2Account, true, ESRecoverableAtOnce, + toString("Can't create dir '%s'", path.c_str()) ); + } + + // download the file + download(res[0], res[1]); + // decompress it + decompressFile(res[1]); + } + if ( mustReDownloadNewDir ) + continue; + gzclose(gz); + gz = 0; + deleteFile(DirFilename, true); + } + while ( mustReDownloadNewDir ); + } + catch ( ERestartApplication& ) + { + mustRestart = true; + } + catch ( ... ) + { + userFriendlyError( Explain1Internal, false, ESUnrecoverable, "Catched '...'" ); + } + } + while ( mustRestart ); + + printf( "The Saga of Ryzom was successfully patched by Ryzom Recover.\nNow you can run the game.\n" ); + + return 0; +} diff --git a/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h b/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h index 1fd931f17..ba77ab9e2 100644 --- a/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h +++ b/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2016 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index f4085cf94..aed92db31 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2016 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt index 731e9e161..4144228d4 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt @@ -1,7 +1,9 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.rc *.rc2) -ADD_LIBRARY(georges_dll SHARED ${SRC} georges_edit.rc) +SOURCE_GROUP("" FILES ${SRC}) + +ADD_LIBRARY(georges_dll SHARED ${SRC}) INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) diff --git a/code/ryzom/tools/leveldesign/georges_dll/action.cpp b/code/ryzom/tools/leveldesign/georges_dll/action.cpp index 6e173756e..520e2b2cf 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/action.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/action.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -44,7 +47,7 @@ IAction::IAction (TTypeAction type, uint selId, uint slot) // *************************************************************************** -void IAction::setLabel (const std::string &logLabel, CGeorgesEditDoc &doc) +void IAction::setLabel (const char *logLabel, CGeorgesEditDoc &doc) { _LogLabel = logLabel; @@ -75,7 +78,7 @@ bool IAction::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool fi // *************************************************************************** -void IAction::update (bool updateLeftView, TUpdateRightView rightViewFlag, CGeorgesEditDoc &doc, const std::string &_FormName) +void IAction::update (bool updateLeftView, TUpdateRightView rightViewFlag, CGeorgesEditDoc &doc, const char *_FormName) { // Right and left view CGeorgesEditView *rightView = doc.getRightView (); @@ -129,7 +132,7 @@ void IAction::update (bool updateLeftView, TUpdateRightView rightViewFlag, CGeor // *************************************************************************** -CActionString::CActionString (IAction::TTypeAction type, const std::string &newValue, CGeorgesEditDoc &doc, const std::string &formName, const std::string &userData, uint selId, uint slot) : IAction (type, selId, slot) +CActionString::CActionString (IAction::TTypeAction type, const char *newValue, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot) : IAction (type, selId, slot) { // Set the new value _NewValue = newValue; @@ -235,7 +238,7 @@ CActionString::CActionString (IAction::TTypeAction type, const std::string &newV bool vdfnArray; CForm *form=doc.getFormPtr (); CFormElm *elm = doc.getRootNode (slot); - nlverify ( elm->getNodeByName (_FormName, &parentDfn, indexDfn, + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); if (node) { @@ -364,7 +367,7 @@ bool CActionString::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, b bool parentVDnfArray; CForm *form=doc.getFormPtr (); CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->getNodeByName (_FormName, &parentDfn, indexDfn, + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDnfArray, true, NLGEORGES_FIRST_ROUND) ); nlassert (node); CFormElmAtom *atom = safe_cast (node); @@ -437,14 +440,14 @@ bool CActionString::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, b bool vdfnArray; CForm *form=doc.getFormPtr (); CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->getNodeByName (_FormName, &parentDfn, indexDfn, + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); if (node) { CFormElmArray* array = safe_cast (node->getParent ()); array->Elements[idInParent].Name = _Value[index]; modified = true; - update (true, DoNothing, doc, _FormName); + update (true, DoNothing, doc, _FormName.c_str ()); } } break; @@ -716,14 +719,14 @@ bool CActionStringVector::doAction (CGeorgesEditDoc &doc, bool redo, bool &modif bool parentVDfnArray; CForm *form=doc.getFormPtr (); CFormElm *elm = doc.getRootNode (slot); - nlverify ( elm->getNodeByName (_FormName, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true) ); + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true) ); // Is a type entry ? if ((type == UFormDfn::EntryType) && array) { // Create the array bool created; - nlverify ( elm->createNodeByName (_FormName, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, created) ); + nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, created) ); nlassert (node); // Get the atom @@ -921,7 +924,7 @@ bool CActionStringVectorVector::doAction (CGeorgesEditDoc &doc, bool redo, bool // *************************************************************************** -CActionBuffer::CActionBuffer(IAction::TTypeAction type, const uint8 *buffer, uint bufferSize, CGeorgesEditDoc &doc, const std::string &formName, const std::string &userData, uint selId, uint slot) : IAction(type, selId, slot) +CActionBuffer::CActionBuffer (IAction::TTypeAction type, const uint8 *buffer, uint bufferSize, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot) : IAction (type, selId, slot) { // New value _FormName = formName; diff --git a/code/ryzom/tools/leveldesign/georges_dll/action.h b/code/ryzom/tools/leveldesign/georges_dll/action.h index 95af8015e..cade0a34d 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/action.h +++ b/code/ryzom/tools/leveldesign/georges_dll/action.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -59,7 +62,7 @@ protected: IAction (TTypeAction type, uint selId, uint slot); // Init log label - void setLabel (const std::string &logLabel, CGeorgesEditDoc &doc); + void setLabel (const char *logLabel, CGeorgesEditDoc &doc); public: @@ -96,7 +99,7 @@ protected: UpdateValues, Redraw }; - void update (bool updateLeftView, TUpdateRightView rightView, CGeorgesEditDoc &doc, const std::string &_FormName); + void update (bool updateLeftView, TUpdateRightView rightView, CGeorgesEditDoc &doc, const char *_FormName); }; // String modification action @@ -105,7 +108,7 @@ class CActionString : public IAction public: // Constructor - CActionString(IAction::TTypeAction type, const std::string &newValue, CGeorgesEditDoc &doc, const std::string &formName, const std::string &userData, uint selId, uint slot); + CActionString (IAction::TTypeAction type, const char *newValue, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot); protected: @@ -165,7 +168,7 @@ class CActionBuffer : public IAction public: // Constructor - CActionBuffer (IAction::TTypeAction type, const uint8 *buffer, uint bufferSize, CGeorgesEditDoc &doc, const std::string &formName, const std::string &userData, uint selId, uint slot); + CActionBuffer (IAction::TTypeAction type, const uint8 *buffer, uint bufferSize, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot); protected: @@ -182,4 +185,5 @@ protected: virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); }; -#endif +#endif /* GEORGES_EDIT_ACTION_H */ + diff --git a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp index a29c9f7d7..cd8c30228 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -230,9 +233,9 @@ BOOL CBaseDialog::PreTranslateMessage(MSG* pMsg) return CDialog::PreTranslateMessage(pMsg); } -void CBaseDialog::setEditTextMultiLine (CEdit &edit, const std::string &text) +void CBaseDialog::setEditTextMultiLine (CEdit &edit, const char *text) { - edit.SetWindowText (utf8ToTStr(NLMISC::addSlashR(text))); + edit.SetWindowText (nlUtf8ToTStr(NLMISC::addSlashR(text))); } void CBaseDialog::onOpenSelected() diff --git a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h index 6358697b7..65acc9f00 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -126,7 +129,7 @@ public: void registerLastControl (); void unRegisterLastControl (); - static void setEditTextMultiLine(CEdit &edit, const std::string &text); + static void setEditTextMultiLine (CEdit &edit, const char *text); virtual void onOpenSelected (); virtual void setFocusLastWidget (); diff --git a/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp b/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp index 37a85329d..941992d34 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -63,7 +66,7 @@ BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/, } // Load state - theApp.loadWindowState (this, "child", true, false); + theApp.loadWindowState (this, _T("child"), true, false); return TRUE; } diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp index 22c556faa..ca6c073d6 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -193,7 +196,7 @@ void CDfnDialog::getFromDocument (const NLGEORGES::CFormDfn &dfn) for (parent=0; parentStruct.ListCtrl.GetItemText (item, 2); std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str)); if (ext == "typ") - Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultType)); + Dialog->Struct.ListCtrl.SetItemText(item, 2, nlUtf8ToTStr(theApp.DefaultType)); } else if ((type == "Dfn") || (type == "Dfn array")) { @@ -430,7 +433,7 @@ void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) str = Dialog->Struct.ListCtrl.GetItemText (item, 2); std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str)); if (ext == "dfn") - Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultDfn)); + Dialog->Struct.ListCtrl.SetItemText(item, 2, nlUtf8ToTStr(theApp.DefaultDfn)); // Clear default value Dialog->Struct.ListCtrl.SetItemText (item, 3, _T("")); @@ -468,16 +471,16 @@ void CDfnDialog::onOpenSelected () int nItem = Parents.ListCtrl.GetNextSelectedItem(pos); // Get the string - std::string str = tStrToUtf8(Parents.ListCtrl.GetItemText (nItem, 0)); - if (!str.empty()) + CString str = Parents.ListCtrl.GetItemText (nItem, 0); + if (str != "") { // Look for the file - string name = CPath::lookup (str, false, false); - if (name.empty ()) + CString name = nlUtf8ToTStr(CPath::lookup(tStrToUtf8(str), false, false)); + if (name.IsEmpty()) name = str; // Open the file - theApp.OpenDocumentFile (utf8ToTStr(name)); + theApp.OpenDocumentFile(name); } } } @@ -490,16 +493,16 @@ void CDfnDialog::onOpenSelected () int nItem = Struct.ListCtrl.GetNextSelectedItem(pos); // Get the string - std::string str = tStrToUtf8(Struct.ListCtrl.GetItemText (nItem, 2)); - if (!str.empty()) + CString str = Struct.ListCtrl.GetItemText (nItem, 2); + if (str != "") { // Look for the file - string name = CPath::lookup (str, false, false); - if (name.empty ()) + CString name = nlUtf8ToTStr(CPath::lookup(tStrToUtf8(str), false, false)); + if (name.IsEmpty()) name = str; // Open the file - theApp.OpenDocumentFile (utf8ToTStr(name)); + theApp.OpenDocumentFile(name); } } } @@ -621,7 +624,7 @@ void CDfnParentEditListCtrl::getNewItemText (uint item, uint subItem, std::strin // *************************************************************************** -void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) +void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, NLMISC::tstring &filter) { filter = DfnFilter; defDir = theApp.RootSearchPath; diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h index 174001aaa..81c04efb4 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -36,7 +39,7 @@ class CDfnParentEditListCtrl : public CEditListCtrl CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); void getNewItemText (uint item, uint subItem, std::string &ret); - void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); + void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, NLMISC::tstring &filter); public: class CDfnDialog *Dialog; }; @@ -47,7 +50,7 @@ class CDfnEditListCtrl : public CEditListCtrl void getComboBoxStrings (uint item, uint subItem, std::vector &retStrings); void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); void getNewItemText (uint item, uint subItem, std::string &ret); - void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); + void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, NLMISC::tstring &filter); void onItemChanged (uint item, uint subItem); public: class CDfnDialog *Dialog; diff --git a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp index 0b16abd4f..522cbb3e4 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -69,7 +72,7 @@ bool CEditListCtrl::create (DWORD wStyle, RECT &rect, CWnd *parent, uint dialog_ Edit.SetFont (ListCtrl.GetFont()); Combo.Create (WS_BORDER|CBS_DROPDOWNLIST, rect, &ListCtrl, IdCombo); Combo.SetFont (ListCtrl.GetFont()); - MemCombo.create (WS_CHILD, rect, &ListCtrl, IdMemCombo, "", theApp.RememberListSize); + MemCombo.create (WS_CHILD, rect, &ListCtrl, IdMemCombo, _T(""), theApp.RememberListSize); MemCombo.SetFont (ListCtrl.GetFont()); return true; } @@ -122,11 +125,11 @@ BOOL CEditListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) // Insert an item at the end string text; getNewItemText (ListCtrl.GetItemCount (), 0, text); - ListCtrl.InsertItem (ListCtrl.GetItemCount (), utf8ToTStr(text)); + ListCtrl.InsertItem(ListCtrl.GetItemCount(), nlUtf8ToTStr(text)); for (uint i=1; igetBrowseInfo (Ctrl->Item, Ctrl->SubItem, defExt, defFilename, defDir, filter); TCHAR buffer[MAX_PATH]; - _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(defDir)); + _tcscpy_s(buffer, MAX_PATH, nlUtf8ToTStr(defDir)); - CFileDialog dlgFile (TRUE, utf8ToTStr(defExt), utf8ToTStr(defFilename), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, utf8ToTStr(filter), theApp.m_pMainWnd); + CFileDialog dlgFile(TRUE, nlUtf8ToTStr(defExt), nlUtf8ToTStr(defFilename), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, nlUtf8ToTStr(filter), theApp.m_pMainWnd); dlgFile.m_ofn.lpstrInitialDir = buffer; Ctrl->OnBrowse = true; if (dlgFile.DoModal () == IDOK) @@ -453,8 +456,8 @@ void CEditListCtrl::editItem (uint item, uint subitem) getComboBoxStrings (Item, SubItem, retStrings); for (uint i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -279,7 +282,7 @@ void CFileBrowserDialog::openDocument () string pathName = CPath::lookup (filename.c_str (), false, false); if (pathName.empty ()) pathName = filename; - theApp.OpenDocumentFile (utf8ToTStr(pathName)); + theApp.OpenDocumentFile(nlUtf8ToTStr(pathName)); } } else if (IsWindow (TreeCtrlType) && TreeCtrlDfn.IsWindowVisible ()) @@ -289,7 +292,7 @@ void CFileBrowserDialog::openDocument () string pathName = CPath::lookup (filename.c_str (), false, false); if (pathName.empty ()) pathName = filename; - theApp.OpenDocumentFile (utf8ToTStr(pathName)); + theApp.OpenDocumentFile(nlUtf8ToTStr(pathName)); } } else if (TreeCtrlForm.IsWindowVisible ()) @@ -299,7 +302,7 @@ void CFileBrowserDialog::openDocument () string pathName = CPath::lookup (filename.c_str (), false, false); if (pathName.empty ()) pathName = filename; - theApp.OpenDocumentFile (utf8ToTStr(pathName)); + theApp.OpenDocumentFile(nlUtf8ToTStr(pathName)); } } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index 3a0616fe1..673c12d9a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -77,8 +80,8 @@ struct CTreeItemInfo pParentFolder=NULL; dwFlags=NULL; } - ITEMIDLIST* pidlSelf; - ITEMIDLIST* pidlFullyQual; + LPITEMIDLIST pidlSelf; + LPITEMIDLIST pidlFullyQual; IShellFolder* pParentFolder; DWORD dwFlags; std::string displayName; @@ -97,8 +100,8 @@ bool CFileTreeCtrl::setRootDirectory (const char *dir) _TreeCtrl.DeleteAllItems (); IShellFolder* pDesktop; - ITEMIDLIST* pidl; - ITEMIDLIST* pidlDir; + LPITEMIDLIST pidl; + LPITEMIDLIST pidlDir; TV_ITEM tvItem={0}; TV_INSERTSTRUCT tvInsert={0}; @@ -318,11 +321,11 @@ BOOL CFileTreeCtrl::OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ) return CWnd::OnNotify ( wParam, lParam, pResult ); } -inline ITEMIDLIST* Pidl_GetNextItem(LPCITEMIDLIST pidl) +inline LPITEMIDLIST Pidl_GetNextItem(LPCITEMIDLIST pidl) { if(pidl) { - return (ITEMIDLIST*)(BYTE*)(((BYTE*)pidl) + pidl->mkid.cb); + return (LPITEMIDLIST)(BYTE*)(((BYTE*)pidl) + pidl->mkid.cb); } else return NULL; @@ -347,7 +350,7 @@ return pidl; UINT Pidl_GetSize(LPCITEMIDLIST pidl) { UINT cbTotal = 0; - ITEMIDLIST* pidlTemp = (ITEMIDLIST*) pidl; + LPITEMIDLIST pidlTemp = (LPITEMIDLIST)pidl; if(pidlTemp) { @@ -415,12 +418,12 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) return 0; } -bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolder, ITEMIDLIST* pidlParent) +bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolder, LPITEMIDLIST pidlParent) { IEnumIDList* pEnum; if(SUCCEEDED(pParentFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS |SHCONTF_FOLDERS|SHCONTF_INCLUDEHIDDEN, &pEnum))) { - ITEMIDLIST* pidl; + LPITEMIDLIST pidl; DWORD dwFetched = 1; TV_ITEM tvItem={0}; TV_INSERTSTRUCT tvInsert={0}; @@ -445,7 +448,7 @@ bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolde nlverify ( SHGetPathFromIDList ( pidl, name ) ); // Save it - pItemInfo->displayName = tStrToUtf8(name); + pItemInfo->displayName = NLMISC::tStrToUtf8(name); // Is a folder ? bool folder = (pItemInfo->dwFlags&SFGAO_FOLDER) !=0; @@ -457,7 +460,9 @@ bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolde string ext5 = pItemInfo->displayName.substr(displayNameSize-5); bool cvs = ext3 == "CVS" || ext4 == "CVS\\" || ext4 == "CVS/" || - ext4 == ".svn" || ext5 == ".svn\\" || ext5 == ".svn/"; + ext4 == ".svn" || ext5 == ".svn\\" || ext5 == ".svn/" || + ext4 == ".hg" || ext5 == ".hg\\" || ext5 == ".hg/" || + ext4 == ".git" || ext5 == ".git\\" || ext5 == ".git/"; /* bool cvs = ( pItemInfo->displayName[displayNameSize-3] == 'C') && (pItemInfo->displayName[displayNameSize-2] == 'V') && @@ -720,7 +725,7 @@ bool CFileTreeCtrl::getCurrentFilename (std::string &result) if (curSel) { CString str = _TreeCtrl.GetItemText (curSel); - result = tStrToUtf8(str); + result = NLMISC::tStrToUtf8(str); return true; } return false; diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h index bdfb5b050..724b5e25e 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -51,7 +54,7 @@ public: bool create( const RECT& rect, CWnd* pParentWnd, UINT nID ); bool setRootDirectory (const char *dir); void setArrangeMode (TArrange arrangeMode); - bool enumObjects (HTREEITEM hParentItem,IShellFolder* pParentFolder, ITEMIDLIST* pidlParent); + bool enumObjects (HTREEITEM hParentItem,IShellFolder* pParentFolder, LPITEMIDLIST pidlParent); void doItemMenu (HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen); void doClick (HWND hwndTreeView, HTREEITEM hItem); void addExclusiveExtFilter (const char *ext); diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index f4fcf4d1d..a4d35fdcc 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -165,7 +168,7 @@ CWnd* CFormDialog::addTypeWidget (const NLGEORGES::CType &type, uint elmIndex, c // Create a reg key string tfn = typeFilename; - string key = GEORGES_EDIT_BASE_REG_KEY"\\"+strlwr (typeFilename)+" MemCombo"; + tstring key = utf8ToTStr(GEORGES_EDIT_BASE_REG_KEY"\\"+strlwr (typeFilename)+" MemCombo"); // Create the widget memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title, key.c_str(), type.UIType==CType::EditSpin, type.UIType==CType::FileBrowser, filenameExt); @@ -251,7 +254,7 @@ void CFormDialog::getVirtualDfnFromDocument (const NLGEORGES::CFormDfn *_dfn, co // Create the widget memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Dfn:", - GEORGES_EDIT_BASE_REG_KEY"\\Virtual Dfn MemCombo", false, true, "*.dfn"); + _T(GEORGES_EDIT_BASE_REG_KEY) _T("\\Virtual Dfn MemCombo"), false, true, "*.dfn"); // Get from document memCombo->getFromDocument (*doc->getFormPtr ()); @@ -462,7 +465,7 @@ void CFormDialog::getArrayFromDocument (const char *structName, uint structId, u // Create the widget memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Array size:", - GEORGES_EDIT_BASE_REG_KEY"\\Array Size MemCombo", true, false, NULL); + _T(GEORGES_EDIT_BASE_REG_KEY) _T("\\Array Size MemCombo"), true, false, NULL); // Get from document memCombo->getFromDocument (*doc->getFormPtr ()); @@ -548,7 +551,7 @@ void CFormDialog::setToDocument (uint widget) bool parentVDfnArray; CForm *form=doc->getFormPtr (); CFormElm *elm = doc->getRootNode (Widgets[widget]->getSlot ()); - nlverify ( elm->getNodeByName (Widgets[widget]->getFormName (), &parentDfn, indexDfn, + nlverify ( elm->getNodeByName (Widgets[widget]->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); // Must create array or virtual dfn ? @@ -811,7 +814,7 @@ BOOL CFormDialog::OnCommand(WPARAM wParam, LPARAM lParam) bool parentVDfnArray; CForm *form=doc->getFormPtr (); CFormElm *elm = doc->getRootNode (Widgets[widgetId]->getSlot ()); - nlverify ( elm->getNodeByName (Widgets[widgetId]->getFormName (), &parentDfn, indexDfn, + nlverify ( elm->getNodeByName (Widgets[widgetId]->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); nlassert (parentDfn); @@ -832,11 +835,11 @@ BOOL CFormDialog::OnCommand(WPARAM wParam, LPARAM lParam) smprintf (filter, 512, "%s Files (%s)|%s|All Files(*.*)|*.*|", typeName+i, ext.c_str(), ext.c_str()); // Open the dialog - CFileDialog dlgFile (TRUE, ext.c_str (), ext.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, theApp.m_pMainWnd); + CFileDialog dlgFile(TRUE, nlUtf8ToTStr(ext), nlUtf8ToTStr(ext), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, nlUtf8ToTStr(filter), theApp.m_pMainWnd); if (dlgFile.DoModal () == IDOK) { combo->Combo.UpdateData (); - combo->Combo.SetWindowText (dlgFile.GetFileName ()); + combo->Combo.SetWindowText(dlgFile.GetFileName()); combo->Combo.UpdateData (FALSE); setToDocument (widgetId); PostMessage (CBN_CHANGED, 0, 0); @@ -850,7 +853,7 @@ BOOL CFormDialog::OnCommand(WPARAM wParam, LPARAM lParam) if (colorEdit && IsWindow (colorEdit->Color)) { colorEdit->Empty = true; - colorEdit->Edit.SetWindowText(""); + colorEdit->Edit.SetWindowText(_T("")); setToDocument (getWidget (wParam)); updateValues (); } @@ -926,7 +929,7 @@ BOOL CFormDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) CString str; combo->Combo.UpdateData (); combo->Combo.GetWindowText (str); - if (sscanf (str, "%f", &value) == 1) + if (_stscanf (str, _T("%f"), &value) == 1) { CGeorgesEditDoc *doc = View->GetDocument(); if (doc) @@ -1166,14 +1169,14 @@ void CFormDialog::getFromDocument () // *************************************************************************** -void CFormDialog::getDfnName (string &result) const +void CFormDialog::getDfnName(string &result) const { CGeorgesEditDoc *doc = View->GetDocument (); if (doc) { // Get the DFN filename - CString str = doc->GetPathName (); - result NLMISC::CFile::getExtension(tStrToUtf8(str)); + CString str = doc->GetPathName(); + result = NLMISC::CFile::getExtension(tStrToUtf8(str)); } else result.clear(); @@ -1316,16 +1319,16 @@ void IFormWidget::updateLabel () switch (where) { case UFormElm::ValueForm: - Label.SetWindowText ((SavedLabel+comp).c_str()); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel + comp)); break; case UFormElm::ValueParentForm: - Label.SetWindowText ((SavedLabel+" (in parent form)"+comp).c_str()); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel + " (in parent form)" + comp)); break; case UFormElm::ValueDefaultDfn: - Label.SetWindowText ((SavedLabel+" (default DFN value)"+comp).c_str()); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel + " (default DFN value)" + comp)); break; case UFormElm::ValueDefaultType: - Label.SetWindowText ((SavedLabel+" (default TYPE value)"+comp).c_str()); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel + " (default TYPE value)" + comp)); break; } } @@ -1352,18 +1355,18 @@ void IFormWidget::updateLabel () if (node->getForm () == doc->getFormPtr ()) { // The node exist - Label.SetWindowText (utf8ToTStr(SavedLabel)); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel)); } else { // The node exist in the parent form - Label.SetWindowText (utf8ToTStr(SavedLabel + " (in parent form)")); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel + " (in parent form)")); } } else { // The node is empty - Label.SetWindowText (utf8ToTStr(SavedLabel + " (undefined)")); + Label.SetWindowText(nlUtf8ToTStr(SavedLabel + " (undefined)")); } } @@ -1512,7 +1515,7 @@ void IFormWidget::onOpenSelected () std::string str2 = CPath::lookup (str, false, false); if (str2.empty()) str2 = str; - theApp.OpenDocumentFile (utf8ToTStr(str2)); + theApp.OpenDocumentFile(nlUtf8ToTStr(str2)); } // *************************************************************************** @@ -1541,7 +1544,7 @@ CFormMemCombo::~CFormMemCombo () // *************************************************************************** -void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool useSpinner, bool fileBrowser, const char *filenameExt) +void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const TCHAR *reg, bool useSpinner, bool fileBrowser, const char *filenameExt) { // Get the doc CGeorgesEditDoc *doc = Dialog->View->GetDocument (); @@ -1569,7 +1572,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, // Create the type combo parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); + Label.Create(nlUtf8ToTStr(label), WS_VISIBLE, currentPos, parent); parent->initWidget (Label); parent->getNextPosLabel (currentPos); @@ -1603,7 +1606,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, RECT spinPos = currentPos; parent->getNextBrowsePos (spinPos); parent->setBrowseSize (spinPos); - Browse.Create ("...", WS_CHILD|WS_VISIBLE|WS_TABSTOP, spinPos, parent, dialog_index+1); + Browse.Create (_T("..."), WS_CHILD|WS_VISIBLE|WS_TABSTOP, spinPos, parent, dialog_index+1); parent->initWidget (Browse); parent->getNextPos (currentPos); @@ -1675,7 +1678,7 @@ void CFormMemCombo::getValue (std::string &result) Combo.UpdateData (FALSE); // Set the atom value - result = (const char*)str; + result = tStrToUtf8(str); } // *************************************************************************** @@ -1691,7 +1694,7 @@ void CFormMemCombo::getFromDocument (CForm &form) if (doc->getRootNode(getSlot ())->getValueByName (result, FormName, UFormElm::NoEval, NULL)) { Combo.UpdateData (); - Combo.SetWindowText (utf8ToTStr(result)); + Combo.SetWindowText(nlUtf8ToTStr(result)); Combo.UpdateData (FALSE); updateLabel (); } @@ -1720,7 +1723,7 @@ void CFormMemCombo::getFromDocument (CForm &form) CFormElmArray *arrayNode = safe_cast (node); char label[512]; smprintf (label, 512, "%d", arrayNode->Elements.size ()); - Combo.SetWindowText (label); + Combo.SetWindowText(nlUtf8ToTStr(label)); if (arrayNode->getForm () == &form) Label.SetWindowText (_T("Array size:")); @@ -1751,7 +1754,7 @@ void CFormMemCombo::getFromDocument (CForm &form) if (node) { CFormElmVirtualStruct *virtualNode = safe_cast (node); - Combo.SetWindowText (utf8ToTStr(virtualNode->DfnFilename)); + Combo.SetWindowText(nlUtf8ToTStr(virtualNode->DfnFilename)); } else { @@ -1903,7 +1906,7 @@ void CFormCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui // Create the type combo parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); + Label.Create(nlUtf8ToTStr(label), WS_VISIBLE, currentPos, parent); parent->initWidget (Label); parent->getNextPosLabel (currentPos); @@ -1918,10 +1921,10 @@ void CFormCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui // Get predefs if (nodeType) { - Combo.InsertString (0, ""); + Combo.InsertString (0, _T("")); for (uint predef=0; predefDefinitions.size(); predef++) { - Combo.InsertString (predef+1, nodeType->Definitions[predef].Label.c_str()); + Combo.InsertString(predef + 1, nlUtf8ToTStr(nodeType->Definitions[predef].Label)); } } @@ -1973,7 +1976,7 @@ void CFormCombo::getValue (std::string &result) Combo.UpdateData (FALSE); // Set the atom value - result = (const char*)str; + result = tStrToUtf8(str); } // *************************************************************************** @@ -2088,13 +2091,13 @@ void CFormBigEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, // Create the type combo parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); + Label.Create(nlUtf8ToTStr(label), WS_VISIBLE, currentPos, parent); parent->initWidget (Label); parent->getNextPosLabel (currentPos); // Create the mem combobox parent->setBigEditSize (currentPos, parent->SmallWidget); - Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index); + Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index); parent->initWidget (Edit); parent->getNextPos (currentPos); @@ -2146,7 +2149,7 @@ void CFormBigEdit::getValue (std::string &result) Edit.UpdateData (FALSE); // Set the atom value - result = (const char*)str; + result = tStrToUtf8(str); } // *************************************************************************** @@ -2262,7 +2265,7 @@ void CColorEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui // Create the type combo parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); + Label.Create(nlUtf8ToTStr(label), WS_VISIBLE, currentPos, parent); parent->initWidget (Label); parent->getNextPosLabel (currentPos); @@ -2275,13 +2278,13 @@ void CColorEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui RECT resetPos = currentPos; parent->getNextColorPos (resetPos); parent->setResetColorSize (resetPos); - Reset.Create ("Reset", WS_CHILD|WS_VISIBLE|WS_TABSTOP, resetPos, parent, dialog_index+1); + Reset.Create (_T("Reset"), WS_CHILD|WS_VISIBLE|WS_TABSTOP, resetPos, parent, dialog_index+1); parent->initWidget (Reset); parent->getNextPosLabel (currentPos); // Create the Edit parent->setBigEditSize (currentPos, parent->SmallWidget); - Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", ES_OEMCONVERT|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL, currentPos, parent, dialog_index+2); + Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), ES_OEMCONVERT|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL, currentPos, parent, dialog_index+2); parent->initWidget (Edit); parent->getNextPos (currentPos); @@ -2492,7 +2495,7 @@ void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the type combo parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); + Label.Create(nlUtf8ToTStr(label), WS_VISIBLE, currentPos, parent); parent->initWidget (Label); parent->getNextPosLabel (currentPos); @@ -2504,7 +2507,7 @@ void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the assign parent parent->setButtonSize (currentPos, parent->SmallWidget); - Button.Create ("Assign parents", WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index+1); + Button.Create (_T("Assign parents"), WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index+1); parent->initWidget (Button); parent->getNextPos (currentPos); @@ -2515,7 +2518,7 @@ void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u void CListWidget::addColumn (const char *name) { - ListCtrl.insertColumn (0, name); + ListCtrl.insertColumn(0, nlUtf8ToTStr(name)); ListCtrl.recalcColumn (); } @@ -2566,7 +2569,7 @@ void CListWidget::getFromDocument (NLGEORGES::CForm &form) string filename = form.getParentFilename (parent); // Insert in the list - ListCtrl.ListCtrl.InsertItem (parent, filename.c_str ()); + ListCtrl.ListCtrl.InsertItem(parent, nlUtf8ToTStr(filename)); ListCtrl.ListCtrl.UpdateData (FALSE); updateLabel (); @@ -2585,7 +2588,7 @@ uint CListWidget::getNumValue () void CListWidget::getValue (std::string &result, uint value) { CString str = ListCtrl.ListCtrl.GetItemText (value, 0); - result = str; + result = tStrToUtf8(str); } // *************************************************************************** @@ -2709,12 +2712,12 @@ void CListWidget::onOpenSelected () if (str != "") { // Look for the file - string name = CPath::lookup ((const char*)str, false, false); - if (name.empty ()) + CString name = nlUtf8ToTStr(CPath::lookup(tStrToUtf8(str), false, false)); + if (name.IsEmpty()) name = str; // Open the file - theApp.OpenDocumentFile (name.c_str ()); + theApp.OpenDocumentFile(name); } } } @@ -2750,7 +2753,7 @@ void CIconWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the type combo parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); + Label.Create(nlUtf8ToTStr(label), WS_VISIBLE, currentPos, parent); parent->initWidget (Label); parent->getNextPosLabel (currentPos); diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h index cb9d29bab..c1e0083c9 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -207,7 +210,7 @@ public: bool FileBrowser; // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool spinner, bool fileBrowser, const char *filenameExt); + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const TCHAR *reg, bool spinner, bool fileBrowser, const char *filenameExt); // From IFormWidget void onOk (); diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index 5b1b5f72f..2941acdc0 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -39,8 +42,8 @@ using namespace NLGEORGES; using namespace std; -const char* TypeFilter = "Type Files (*.typ)|*.typ|All Files (*.*)|*.*||"; -const char* DfnFilter = "Form Definition Files (*.dfn)|*.dfn|All Files (*.*)|*.*||"; +const TCHAR* TypeFilter = _T("Type Files (*.typ)|*.typ|All Files (*.*)|*.*||"); +const TCHAR* DfnFilter = _T("Form Definition Files (*.dfn)|*.dfn|All Files (*.*)|*.*||"); CSplashScreen* splashScreen=new CSplashScreen; ///////////////////////////////////////////////////////////////////////////// // CGeorgesEditApp @@ -477,9 +480,9 @@ void CGeorgesEditApp::OnAppAbout() void CGeorgesEditApp::outputError (const char* message) { if (m_pMainWnd) - m_pMainWnd->MessageBox (utf8ToTStr(message), _T("Georges Edit"), MB_OK|MB_ICONEXCLAMATION); + m_pMainWnd->MessageBox(nlUtf8ToTStr(message), _T("Georges Edit"), MB_OK | MB_ICONEXCLAMATION); else - MessageBox (NULL, utf8ToTStr(message), _T("Georges Edit"), MB_OK|MB_ICONEXCLAMATION); + MessageBox(NULL, nlUtf8ToTStr(message), _T("Georges Edit"), MB_OK | MB_ICONEXCLAMATION); } void CGeorgesEditApp::getConfigFilePath (std::string &output) @@ -711,9 +714,9 @@ bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color) bool CGeorgesEditApp::yesNo (const char* message) { if (m_pMainWnd) - return m_pMainWnd->MessageBox (message, _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO; + return m_pMainWnd->MessageBox(nlUtf8ToTStr(message), _T("Georges Edit"), MB_YESNO | MB_ICONQUESTION) != IDNO; else - return MessageBox (NULL, message, _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO; + return MessageBox(NULL, nlUtf8ToTStr(message), _T("Georges Edit"), MB_YESNO | MB_ICONQUESTION) != IDNO; } void CGeorgesEditApp::loadPlugins () @@ -722,7 +725,7 @@ void CGeorgesEditApp::loadPlugins () for (i=0; iSetPathName ( pathName, FALSE ); + doc->SetPathName (nlUtf8ToTStr(pathName), FALSE ); // Create the file - doc->OnSaveDocument( pathName ); + doc->OnSaveDocument(nlUtf8ToTStr(pathName)); } // Init the frame @@ -908,10 +911,10 @@ LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) if (retval == ERROR_SUCCESS) { - long datasize = MAX_PATH; - char data[MAX_PATH]; + long datasize = MAX_PATH * sizeof(TCHAR); + TCHAR data[MAX_PATH]; RegQueryValue(hkey, NULL, data, &datasize); - lstrcpy(retdata,data); + lstrcpy(retdata, data); RegCloseKey(hkey); } @@ -925,7 +928,7 @@ void CGeorgesEditApp::gotoURL (LPCTSTR url) void CGeorgesEditApp::WinHelp(DWORD dwData, UINT nCmd) { - gotoURL(utf8ToTStr(NLMISC::CFile::getPath(ExePath) + "georges_edit.html")); + gotoURL(nlUtf8ToTStr(NLMISC::CFile::getPath(ExePath) + "georges_edit.html")); } void CGeorgesEditApp::OnViewRefresh() @@ -936,7 +939,7 @@ void CGeorgesEditApp::OnViewRefresh() } } -void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool controlBar) +void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const TCHAR *name, bool controlBar) { HKEY hKey; nlverify (RegCreateKey (HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Windows states"), &hKey) == ERROR_SUCCESS); @@ -952,7 +955,7 @@ void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool c nlverify (RegCloseKey (hKey) == ERROR_SUCCESS); } -void CGeorgesEditApp::loadWindowState (CWnd *wnd, const char *name, bool mdiChildWnd, bool controlBar) +void CGeorgesEditApp::loadWindowState (CWnd *wnd, const TCHAR *name, bool mdiChildWnd, bool controlBar) { HKEY hKey; if (RegOpenKey (HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Windows states"), &hKey) == ERROR_SUCCESS) @@ -993,20 +996,20 @@ void CGeorgesEditApp::saveState () // Save the main window state nlassert (m_pMainWnd); if (ResizeMain) - saveWindowState (m_pMainWnd, "main", false); + saveWindowState (m_pMainWnd, _T("main"), false); - saveWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", true); - saveWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", true); + saveWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, _T("browser"), true); + saveWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, _T("output"), true); } void CGeorgesEditApp::loadState () { nlassert (m_pMainWnd); if (ResizeMain) - loadWindowState (m_pMainWnd, "main", false, false); + loadWindowState (m_pMainWnd, _T("main"), false, false); - loadWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", false, true); - loadWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", false, true); + loadWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, _T("browser"), false, true); + loadWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, _T("output"), false, true); } void CGeorgesEditApp::OnFileSaveAll() @@ -1025,7 +1028,7 @@ void CGeorgesEditApp::OnUpdateFileSaveAll(CCmdUI* pCmdUI) pCmdUI->Enable (getActiveDocument () != NULL); } -bool CGeorgesEditApp::SerialIntoMemStream (const std::string &formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard) +bool CGeorgesEditApp::SerialIntoMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard) { // Ok, get the node const CFormDfn *parentDfn; @@ -1060,7 +1063,7 @@ bool CGeorgesEditApp::SerialIntoMemStream (const std::string &formName, CGeorges { // Get the string CString str = doc->GetPathName (); - name = str; + name = tStrToUtf8(str); uint pos = name.rfind ('.'); if (pos != string::npos) { @@ -1088,27 +1091,27 @@ bool CGeorgesEditApp::SerialIntoMemStream (const std::string &formName, CGeorges { if (array) { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), std::string()); } else { if (type == UFormDfn::EntryDfn) { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), std::string()); } else if (type == UFormDfn::EntryVirtualDfn) { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), std::string()); } else if (type == UFormDfn::EntryType) { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), std::string()); } } } else { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), std::string()); } } @@ -1228,7 +1231,7 @@ bool CGeorgesEditApp::FillMemStreamWithClipboard (const char *formName, CGeorges return false; } -bool CGeorgesEditApp::SerialFromMemStream (const std::string &formName, CGeorgesEditDoc *doc, uint slot) +bool CGeorgesEditApp::SerialFromMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot) { // The form pointer CForm *form = doc->getFormPtr (); @@ -1268,7 +1271,7 @@ bool CGeorgesEditApp::SerialFromMemStream (const std::string &formName, CGeorges { // Get the string CString str = doc->GetPathName (); - nameParent = str; + nameParent = tStrToUtf8(str); uint pos = nameParent.rfind ('.'); if (pos != string::npos) { @@ -1423,24 +1426,24 @@ bool CGeorgesEditApp::SerialFromMemStream (const std::string &formName, CGeorges BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) { - if (strncmp (lpszCommand, "Open", 4) == 0) + if (_tcsncmp (lpszCommand, _T("Open"), 4) == 0) { - string name = lpszCommand; + tstring name = lpszCommand; name = name.substr (6, name.size ()-8); OpenDocumentFile (name.c_str ()); } - else if (strncmp (lpszCommand, "Georges Copy", 4) == 0) + else if (_tcsncmp(lpszCommand, _T("Georges Copy"), 4) == 0) { // Get ext name - string name = lpszCommand; + tstring name = lpszCommand; name = name.substr (6, name.size ()-8); // Get the extension - std::string ext = NLMISC::CFile::getExtension(name); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(name.c_str())); string dfnName = ext + ".dfn"; // Get the doc template - CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ()); + CMultiDocTemplate *docTemplate = getFormDocTemplate(dfnName.c_str()); if (docTemplate) { @@ -1452,7 +1455,7 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) // Create the frame CFrameWnd* pFrame = docTemplate->CreateNewFrame(doc, NULL); nlassert (pFrame); - if (doc->loadFormFile (name.c_str ())) + if (doc->loadFormFile(tStrToUtf8(name.c_str()).c_str())) { doc->updateDocumentStructure (); @@ -1491,21 +1494,21 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) outputError (tmp); } } - else if (strncmp (lpszCommand, "Derive", 6) == 0) + else if (_tcsncmp(lpszCommand, _T("Derive"), 6) == 0) { // Get ext name - string name = lpszCommand; + tstring name = lpszCommand; name = name.substr (8, name.size ()-10); // Get the extension - std::string ext = NLMISC::CFile::getExtension(name); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(name.c_str())); string dfnName = ext + ".dfn"; // Create a document CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); if (doc) { - std::string nameFile = NLMISC::CFile::getFilename(name); + std::string nameFile = NLMISC::CFile::getFilename(tStrToUtf8(name.c_str())); doc->addParent (nameFile.c_str()); doc->updateDocumentStructure (); doc->UpdateAllViews (NULL); @@ -1517,14 +1520,14 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) outputError (tmp); } } - else if (strncmp (lpszCommand, "CreateForm", 10) == 0) + else if (_tcsncmp(lpszCommand, _T("CreateForm"), 10) == 0) { // Get ext name - string name = lpszCommand; + tstring name = lpszCommand; name = name.substr (10, name.size ()-12); // Get the extension - std::string dfnName = NLMISC::CFile::getFilename(name); + std::string dfnName = NLMISC::CFile::getFilename(tStrToUtf8(name.c_str())); // Create a document CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h index 747e4aec7..e86b7bacc 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -41,8 +44,8 @@ #define GEORGES_EDIT_BASE_REG_KEY "Software\\Nevrax\\Georges Edit" #define GEORGES_EDIT_BROWSE_LABEL "--- Browse..." -extern const char* TypeFilter; -extern const char* DfnFilter; +extern const TCHAR* TypeFilter; +extern const TCHAR* DfnFilter; class CGeorgesEditDoc; @@ -119,11 +122,11 @@ public: public: // Memory stream NLMISC::CMemStream MemStream; - bool FillMemStreamWithClipboard (const std::string &formName, CGeorgesEditDoc *doc, uint slot); + bool FillMemStreamWithClipboard (const char *formName, CGeorgesEditDoc *doc, uint slot); void FillMemStreamWithBuffer (const uint8 *buffer, uint size); - bool SerialIntoMemStream (const std::string &formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard); - bool SerialFromMemStream (const std::string &formName, CGeorgesEditDoc *doc, uint slot); + bool SerialIntoMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard); + bool SerialFromMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot); // Init BOOL initInstance (int nCmdShow, bool exeStandalone, int x, int y, int cx, int cy); @@ -136,7 +139,7 @@ public: // From IEdit NLGEORGES::IEditDocument *getActiveDocument (); - NLGEORGES::IEditDocument *createDocument (const std::string &dfnName, const std::string &pathName); + NLGEORGES::IEditDocument *createDocument (const char *dfnName, const char *pathName); virtual void getSearchPath (std::string &searchPath); virtual NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } @@ -153,10 +156,10 @@ public: CImageListEx ImageList; // Get a template form - CMultiDocTemplate *getFormDocTemplate (const std::string &dfnName); + CMultiDocTemplate *getFormDocTemplate (const char *dfnName); - void saveWindowState (const CWnd *wnd, const std::string &name, bool controlBar); - void loadWindowState (CWnd *wnd, const std::string &name, bool changeShowWindow, bool controlBar); + void saveWindowState (const CWnd *wnd, const TCHAR *name, bool controlBar); + void loadWindowState (CWnd *wnd, const TCHAR *name, bool changeShowWindow, bool controlBar); // Overrides // ClassWizard generated virtual function overrides @@ -176,8 +179,8 @@ public: void releasePlugins (); // Dialog function - void outputError (const std::string &message); - bool yesNo (const std::string &message); + void outputError (const char* message); + bool yesNo (const char* message); bool getColor (NLMISC::CRGBA &color); // Browse an URL diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.rc b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.rc index d8ef47a49..24a4a259a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.rc +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.rc @@ -13,11 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// English resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL #pragma code_page(1252) #endif //_WIN32 @@ -52,6 +52,8 @@ BEGIN "#include ""res\\georges_edit.rc2"" // non-Microsoft Visual C++ edited resources\r\n" "#include ""afxres.rc"" // Standard components\r\n" "#endif\r\n" + "\r\n" + "#include ""version.rc2""\r\n" "\0" END @@ -452,18 +454,6 @@ END // Dialog // -IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Georges Edit" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "Georges Edit Version 1.24",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Nevrax Copyright (C) 2002",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP -END - IDR_MAINFRAME DIALOG DISCARDABLE 0, 0, 330, 16 STYLE WS_CHILD FONT 8, "MS Sans Serif" @@ -522,52 +512,6 @@ BEGIN END -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "\0" - VALUE "FileDescription", "Georges Edit MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "Georges Edit\0" - VALUE "LegalCopyright", "Copyright (C) 2002\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "georges_edit.EXE\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "Georges Edit Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -788,18 +732,6 @@ BEGIN ID_BUTTON32803 "Hold content in buffer 4\nHold 4" END -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// French (France) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) -#ifdef _WIN32 -LANGUAGE LANG_FRENCH, SUBLANG_FRENCH -#pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -833,7 +765,7 @@ BEGIN END #endif // APSTUDIO_INVOKED -#endif // French (France) resources +#endif // English resources ///////////////////////////////////////////////////////////////////////////// @@ -856,6 +788,8 @@ LANGUAGE 9, 1 #include "afxres.rc" // Standard components #endif +#include "version.rc2" + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp index 0bc32cfc9..d7dcd6b89 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -182,8 +185,8 @@ bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement) // Set file name and title std::string name2 = toLower(NLMISC::CFile::getFilenameWithoutExtension(dfnName)); - SetPathName (utf8ToTStr("*." + name2), FALSE); - SetTitle (utf8ToTStr("New " + name2 + " form")); + SetPathName(nlUtf8ToTStr("*." + name2), FALSE); + SetTitle(nlUtf8ToTStr("New " + name2 + " form")); // TMp if (newElement) @@ -223,10 +226,10 @@ BOOL CGeorgesEditDocForm::OnNewDocument() string defFilename = theApp.RootSearchPath; defFilename += "*.dfn"; - CFileDialog dlgFile (TRUE, _T("*.dfn"), defFilename.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, DfnFilter, theApp.m_pMainWnd); + CFileDialog dlgFile(TRUE, _T("*.dfn"), nlUtf8ToTStr(defFilename.c_str()), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, DfnFilter, theApp.m_pMainWnd); if (dlgFile.DoModal () == IDOK) { - if (initDocument (dlgFile.GetFileName (), true)) + if (initDocument(tStrToUtf8(dlgFile.GetFileName()).c_str(), true)) return TRUE; } } @@ -491,7 +494,7 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) try { // Read the form with the loader - Type = FormLoader.loadType (lpszPathName); + Type = FormLoader.loadType(tStrToUtf8(lpszPathName)); if (!Type) { char msg[512]; @@ -517,11 +520,11 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) try { // Read the form with the loader - Dfn = FormLoader.loadFormDfn (lpszPathName, true); + Dfn = FormLoader.loadFormDfn (tStrToUtf8(lpszPathName), true); if (!Dfn) { char msg[512]; - smprintf (msg, 512, "Error while loading Dfn file %s", lpszPathName); + smprintf (msg, 512, "Error while loading Dfn file %s", tStrToUtf8(lpszPathName).c_str()); theApp.outputError (msg); return FALSE; } @@ -554,13 +557,13 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) if (theApp.getFormDocTemplate (dfnName.c_str ()) == NULL) { char message[512]; - smprintf (message, 512, "Can't open the file '%s'.", lpszPathName); + smprintf (message, 512, "Can't open the file '%s'.", tStrToUtf8(lpszPathName).c_str()); theApp.outputError (message); return FALSE; } // Read the form with the loader - if (!loadFormFile (lpszPathName)) + if (!loadFormFile (tStrToUtf8(lpszPathName).c_str())) return FALSE; if (theApp.ExeStandalone) @@ -743,7 +746,7 @@ BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName) // Open the filt COFile file; - if (file.open (lpszPathName)) + if (file.open(tStrToUtf8(lpszPathName))) { try { @@ -778,7 +781,7 @@ BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName) Dfn->Header.MinorVersion++; flushValueChange (); } - Dfn->write (xmlStream.getDocument (), lpszPathName); + Dfn->write (xmlStream.getDocument (), tStrToUtf8(lpszPathName)); modify (NULL, NULL, false); UpdateAllViews (NULL); return TRUE; @@ -793,11 +796,11 @@ BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName) ((CForm*)(UForm*)Form)->Header.MinorVersion++; flushValueChange (); } - ((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName); - if (strcmp (xmlStream.getErrorString (), "") != 0) + ((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), tStrToUtf8(lpszPathName)); + if (strcmp(xmlStream.getErrorString().c_str(), "") != 0) { char message[512]; - smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString ()); + smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString().c_str()); theApp.outputError (message); } modify (NULL, NULL, false); @@ -1122,7 +1125,7 @@ void CGeorgesEditDoc::getFilename (std::string &pathname) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - pathname = (const char*)GetPathName (); + pathname = tStrToUtf8(GetPathName()); } // *************************************************************************** @@ -1131,7 +1134,7 @@ void CGeorgesEditDoc::getTitle (std::string &title) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - title = (const char*)GetTitle (); + title = tStrToUtf8(GetTitle()); } // *************************************************************************** @@ -1327,11 +1330,11 @@ void CGeorgesEditDoc::setModifiedState (bool modified) } else { - string title = (const char*)GetTitle (); + string title = tStrToUtf8(GetTitle()); if ( (title.size ()>=2) && (title[title.size()-1] == '*') && (title[title.size()-2] == ' ') ) { title.resize (title.size () - 2); - SetTitle (title.c_str()); + SetTitle(nlUtf8ToTStr(title)); } } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp index e59fcb373..d8181e2fa 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -295,7 +298,7 @@ void CGeorgesEditView::updateTab () // Init the tab CGeorgesEditDocSub *child = parent->getChild (i); int image = child->getItemImage (doc); - TabCtrl.InsertItem (i, utf8ToTStr(child->getName()), image); + TabCtrl.InsertItem(i, nlUtf8ToTStr(child->getName()), image); // This is the selection ? if (subObject == child) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp index 2ac3ed596..2eaddc4b7 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -579,12 +582,12 @@ void CGeorgesImpl::LoadDocument( const std::string& _sxfullname ) AFX_MANAGE_STATE(AfxGetStaticModuleState()); try { - theApp.OpenDocumentFile(_sxfullname.c_str()); + theApp.OpenDocumentFile(nlUtf8ToTStr(_sxfullname)); } catch (const NLMISC::Exception &e) { std::string tmp = std::string(e.what()) + "(" + _sxfullname + ")"; - theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); + theApp.m_pMainWnd->MessageBox(nlUtf8ToTStr(tmp), _T("Georges_Lib"), MB_ICONERROR | MB_OK); } } @@ -666,7 +669,7 @@ IGeorges* IGeorges::getInterface (int version) // Check version number if (version != GEORGES_VERSION) { - MessageBox (NULL, "Bad version of georges.dll.", "Georges", MB_ICONEXCLAMATION|MB_OK); + MessageBox(NULL, _T("Bad version of georges.dll."), _T("Georges"), MB_ICONEXCLAMATION | MB_OK); return NULL; } else diff --git a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp index 8bdf3e165..a1443d8af 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -86,20 +89,20 @@ BOOL CHeaderDialog::OnInitDialog() // Create the version setStaticSize (currentPos); - char versionText[512]; - smprintf (versionText, 512, "Version %d.%d", 0, 0); + CString versionText; + versionText.Format(_T("Version %d.%d"), 0, 0); LabelVersion.Create (versionText, WS_VISIBLE, currentPos, this); initWidget (LabelVersion); getNextPosLabel (currentPos); setButtonSize (currentPos, SmallWidget); - IncrementVersion.Create ("Increment Version", WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); + IncrementVersion.Create (_T("Increment Version"), WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); initWidget (IncrementVersion); getNextPos (currentPos); // Create the state combo setStaticSize (currentPos); - LabelState.Create ("State:", WS_VISIBLE, currentPos, this); + LabelState.Create (_T("State:"), WS_VISIBLE, currentPos, this); initWidget (LabelState); getNextPosLabel (currentPos); @@ -109,30 +112,30 @@ BOOL CHeaderDialog::OnInitDialog() ComboState.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbState); uint item; for (item=0; itemmodify (new CActionString (IAction::HeaderVersion, name, *doc, "", "", + doc->modify(new CActionString(IAction::HeaderVersion, tStrToUtf8(name).c_str(), *doc, "", "", doc->getLeftView ()->getCurrentSelectionId (), 0)); } } @@ -299,7 +302,7 @@ void CHeaderDialog::setCommentsToDocument () CGeorgesEditDocSub *current = doc->getSelectedObject (); CString str; Comments.GetWindowText (str); - doc->modify (new CActionString (IAction::HeaderComments, str, *doc, "", "", + doc->modify(new CActionString(IAction::HeaderComments, tStrToUtf8(str).c_str(), *doc, "", "", doc->getLeftView ()->getCurrentSelectionId (), 0)); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp index 5a28d65e6..9eb9661d9 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -85,7 +88,7 @@ void CIconWnd::create (DWORD wStyle, RECT &pos, CWnd *parent, uint dialogIndex) LPCTSTR className = AfxRegisterWndClass(CS_OWNDC); // Create this window - CWnd::Create(className, "empty", wStyle, pos, parent, dialogIndex); + CWnd::Create(className, _T("empty"), wStyle, pos, parent, dialogIndex); } bool CIconWnd::updateStr() @@ -283,14 +286,15 @@ void CIconWnd::addIconLayer(NLMISC::CBitmap &dst, const std::string iconStr, con bool CIconWnd::updateWnd(CWnd *pWnd, std::string &str) { - char buffer[512]; + TCHAR buffer[512]; if (pWnd) { pWnd->GetWindowText(buffer, 512); - if (buffer != str) + std::string buf = tStrToUtf8(buffer); + if (buf != str) { - str = buffer; + str = buf; return true; } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp index 590e98a25..824da9f2a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -27,7 +30,7 @@ using namespace NLMISC; #pragma warning (disable : 4786) -BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCSTR lpszType, LPCSTR lpszName, WORD wIDLanguage, +BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) { set *iconNames = (set*)lParam; @@ -96,7 +99,7 @@ void CImageListEx::addResourceIcon (const char *filename) int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; // Load the icon - HICON handle = (HICON) LoadImage (NULL, filename, IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); + HICON handle = (HICON)LoadImage(NULL, nlUtf8ToTStr(filename), IMAGE_ICON, width, height, LR_COLOR | LR_LOADFROMFILE); if (handle) { // Copy the icon diff --git a/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp index 5f699dafe..c0d8a69d9 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -109,14 +112,14 @@ void CLeftView::getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, H if (!item) { int itemImage = subObject->getItemImage (GetDocument()); - item = TreeCtrl.InsertItem (subObject->getName ().c_str(), itemImage, itemImage, parent); + item = TreeCtrl.InsertItem(nlUtf8ToTStr(subObject->getName()), itemImage, itemImage, parent); } // Set name - TreeCtrl.SetItemText (item, subObject->getName ().c_str()); + TreeCtrl.SetItemText(item, nlUtf8ToTStr(subObject->getName())); // Set item data - TreeCtrl.SetItemData (item, (DWORD)subObject); + TreeCtrl.SetItemData (item, (DWORD_PTR)subObject); // For each children HTREEITEM child = TreeCtrl.GetChildItem (item); @@ -351,8 +354,8 @@ BOOL CLeftView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { // Change the node name TreeCtrl.SetItemText (ptvdi->item.hItem, ptvdi->item.pszText); - doc->modify (new CActionString (IAction::FormArrayRename, ptvdi->item.pszText, *doc, - subObject->getFormName ().c_str (), toString (subObject->getIdInParent ()).c_str(), + doc->modify (new CActionString(IAction::FormArrayRename, tStrToUtf8(ptvdi->item.pszText).c_str(), *doc, + subObject->getFormName().c_str(), toString (subObject->getIdInParent()).c_str(), doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); return TRUE; } @@ -878,7 +881,7 @@ void CLeftView::OnDelete() CEdit *edit = TreeCtrl.GetEditControl(); if (edit) { - edit->SetWindowText (""); + edit->SetWindowText (_T("")); } else { diff --git a/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp b/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp index 02c06fdde..af19420fb 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -163,7 +166,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) AssertLog->addDisplayer (&Displayer); // JC: added LoadBarState - LoadBarState("Georges"); + LoadBarState(_T("Georges")); return 0; } @@ -322,7 +325,7 @@ void CMainFrame::OnClose() if (theApp.SaveAllModified()) { // JC: added save bar state - SaveBarState("Georges"); + SaveBarState(_T("Georges")); // Save state theApp.saveState (); @@ -436,7 +439,7 @@ void CMainFrame::OnUpdateModules0(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[0].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText(nlUtf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[0].Activated); } else @@ -464,7 +467,7 @@ void CMainFrame::OnUpdateModules1(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[1].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText(nlUtf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[1].Activated); } else @@ -492,7 +495,7 @@ void CMainFrame::OnUpdateModules2(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[2].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText(nlUtf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[2].Activated); } else @@ -520,7 +523,7 @@ void CMainFrame::OnUpdateModules3(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[3].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText(nlUtf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[3].Activated); } else diff --git a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp index 7380a3d31..8e2152c52 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -43,7 +46,7 @@ CMemoryComboBox::~CMemoryComboBox() // *************************************************************************** -void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount) +void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const TCHAR *registerAdress, int memoryCount) { // Register a window Id = nId; @@ -52,7 +55,7 @@ void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT LPCTSTR clas = AfxRegisterWndClass (0); if (clas) { - if (Create (clas, "MemoryComboBox", style, rect, parent, nId)) + if (Create (clas, _T("MemoryComboBox"), style, rect, parent, nId)) { // Create the combo box RECT comboRect; @@ -95,16 +98,16 @@ bool CMemoryComboBox::getMemory (int slot, std::string &ret) { // Open the key HKEY hKey; - if (RegOpenKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + if (RegOpenKey(HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) { // Get the value char strSrc[512]; smprintf (strSrc, 512, "%d", slot); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + TCHAR str[512]; + LONG size = 512 * sizeof(TCHAR); + if (RegQueryValue(hKey, nlUtf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { - ret = str; + ret = tStrToUtf8(str); // Close RegCloseKey (hKey); @@ -132,14 +135,14 @@ void CMemoryComboBox::scrollDown (int start, int end) // Get the old value char strSrc[512]; smprintf (strSrc, 512, "%d", i-1); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + TCHAR str[512]; + LONG size = 512 * sizeof(TCHAR); + if (RegQueryValue (hKey, nlUtf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { // Set the value char strDst[512]; smprintf (strDst, 512, "%d", i); - RegSetValue (hKey, strDst, REG_SZ, str, size); + RegSetValue (hKey, nlUtf8ToTStr(strDst), REG_SZ, str, size); } } @@ -157,7 +160,8 @@ void CMemoryComboBox::pushString (const std::string &str) if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) { // Set the value - RegSetValue (hKey, _T("0"), REG_SZ, str.c_str (), str.size ()); + tstring tstr = utf8ToTStr(str); + RegSetValue (hKey, _T("0"), REG_SZ, tstr.c_str(), (tstr.size() + 1) * sizeof(TCHAR)); // Close RegCloseKey (hKey); @@ -443,7 +447,7 @@ void CMemoryComboBox::refreshStrings () int count = Commands.size(); for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -46,11 +49,11 @@ public: void onOK (); void onCancel (); - void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount); + void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const TCHAR *registerAdress, int memoryCount); void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId); - void setRegisterAdress(const std::string ®isterAdress); + void setRegisterAdress (const TCHAR *registerAdress); void clearCommand (); - void addCommand(const std::string &commandLabel, uint commandId); + void addCommand (const char* commandLabel, uint commandId); void clearStaticStrings (); void addStaticStrings (const char* strings); uint getCommandCount () const; @@ -59,7 +62,7 @@ public: bool isWnd (const CWnd *wnd) const; void enableAutoCompleteExtension (bool enable, const char * ext); - std::string RegisterAdress; + NLMISC::tstring RegisterAdress; int MemoryCount; UINT Id; diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp index abb81b933..d33fbf4b5 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -98,7 +101,7 @@ void COutputConsoleDlg::outputString (const char *message) { int index = edit->LineIndex(edit->GetLineCount( )-1) + edit->LineLength(edit->GetLineCount( )-1); edit->SetSel (index, index); - edit->ReplaceSel (message); + edit->ReplaceSel(nlUtf8ToTStr(message)); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h index cdc9a4745..f521480e2 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2012 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp index c92f2be16..8ac6e9409 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -21,50 +24,53 @@ using namespace std; using namespace NLMISC; -void deleteKey (HKEY hKey, const char *name) +void deleteKey(HKEY hKey, const TCHAR *name) { HKEY subKey; - if (RegOpenKey (hKey, name, &subKey) == ERROR_SUCCESS) + if (RegOpenKey(hKey, name, &subKey) == ERROR_SUCCESS) { - char subName[512]; - while (RegEnumKey (subKey, 0, subName, 512) == ERROR_SUCCESS) + TCHAR subName[512]; + while (RegEnumKey(subKey, 0, subName, 512) == ERROR_SUCCESS) { - deleteKey (subKey, subName); + deleteKey(subKey, subName); } - nlverify (RegDeleteKey (hKey, name) == ERROR_SUCCESS); + nlverify(RegDeleteKey(hKey, name) == ERROR_SUCCESS); } } // Register an application -bool RegisterApp (const char *appName, const char *appDescription, const char *icon, int iconIndex) +bool RegisterApp(const char *appName, const char *appDescription, const char *icon, int iconIndex) { // Create the app key HKEY hKey; - if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + if (RegCreateKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(appName), &hKey) == ERROR_SUCCESS) { // Set the description - RegSetValue (hKey, "", REG_SZ, appDescription, strlen (appDescription)); - + tstring tAppDescription = utf8ToTStr(appDescription); + RegSetValue(hKey, _T(""), REG_SZ, tAppDescription.c_str(), (tAppDescription.size() + 1) * sizeof(TCHAR)); + // Create the icon HKEY hKey2; - if (RegCreateKey (hKey, "DefaultIcon", &hKey2) == ERROR_SUCCESS) + if (RegCreateKey(hKey, _T("DefaultIcon"), &hKey2) == ERROR_SUCCESS) { // Set the description char tmp[512]; - smprintf (tmp, 512, "%s,%d", icon, iconIndex); - RegSetValue (hKey2, "", REG_SZ, tmp, strlen (tmp)); + smprintf(tmp, 512, "%s,%d", icon, iconIndex); + tstring ttmp = utf8ToTStr(tmp); + RegSetValue(hKey2, _T(""), REG_SZ, ttmp.c_str(), (ttmp.size() + 1) * sizeof(TCHAR)); } // Create the shell/open/command - if (RegCreateKey (hKey, "shell", &hKey) == ERROR_SUCCESS) + if (RegCreateKey(hKey, _T("shell"), &hKey) == ERROR_SUCCESS) { - if (RegCreateKey (hKey, "open", &hKey) == ERROR_SUCCESS) + if (RegCreateKey(hKey, _T("open"), &hKey) == ERROR_SUCCESS) { - if (RegCreateKey (hKey, "command", &hKey) == ERROR_SUCCESS) + if (RegCreateKey(hKey, _T("command"), &hKey) == ERROR_SUCCESS) { // Set the description - string tmp = string(icon)+" \"%1\""; - RegSetValue (hKey, "", REG_SZ, tmp.c_str(), tmp.size()); + string tmp = string(icon) + " \"%1\""; + tstring ttmp = utf8ToTStr(tmp); + RegSetValue(hKey, _T(""), REG_SZ, ttmp.c_str(), (ttmp.size() + 1) * sizeof(TCHAR)); } } } @@ -75,43 +81,44 @@ bool RegisterApp (const char *appName, const char *appDescription, const char *i } // Unregister an application -bool UnregisterApp (const char *appName) +bool UnregisterApp(const char *appName) { // Delete the app key - deleteKey (HKEY_CLASSES_ROOT, appName); + deleteKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(appName)); return true; } // Unregister an application command -bool UnregisterAppCommand (const char *appName, const char *command) +bool UnregisterAppCommand(const char *appName, const char *command) { // Create the app key HKEY hKey; - if (RegOpenKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + if (RegOpenKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(appName), &hKey) == ERROR_SUCCESS) { // Create the icon char tmp[512]; - smprintf (tmp, 512, "shell\\%s", command); - deleteKey (hKey, tmp); + smprintf(tmp, 512, "shell\\%s", command); + deleteKey(hKey, nlUtf8ToTStr(tmp)); return true; } return false; } // Register an application command -bool RegisterAppCommand (const char *appName, const char *command, const char *app) +bool RegisterAppCommand(const char *appName, const char *command, const char *app) { // Create the app key HKEY hKey; - if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + if (RegCreateKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(appName), &hKey) == ERROR_SUCCESS) { // Create the icon char tmp[512]; - smprintf (tmp, 512, "shell\\%s\\command", command); - if (RegCreateKey (hKey, tmp, &hKey) == ERROR_SUCCESS) + smprintf(tmp, 512, "shell\\%s\\command", command); + if (RegCreateKey(hKey, nlUtf8ToTStr(tmp), &hKey) == ERROR_SUCCESS) { // Set the description - RegSetValue (hKey, "", REG_SZ, app, strlen (app)); + tstring tapp = utf8ToTStr(app); + RegSetValue(hKey, _T(""), REG_SZ, tapp.c_str(), (tapp.size() + 1) * sizeof(TCHAR)); } return true; } @@ -119,41 +126,43 @@ bool RegisterAppCommand (const char *appName, const char *command, const char *a } // Unregister an application DDE command -bool UnregisterDDECommand (const char *appName, const char *command) +bool UnregisterDDECommand(const char *appName, const char *command) { // Create the app key HKEY hKey; - if (RegOpenKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + if (RegOpenKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(appName), &hKey) == ERROR_SUCCESS) { // Create the icon char tmp[512]; - smprintf (tmp, 512, "shell\\%s\\ddeexec", command); - deleteKey (hKey, tmp); + smprintf(tmp, 512, "shell\\%s\\ddeexec", command); + deleteKey(hKey, nlUtf8ToTStr(tmp)); } return false; } // Register an application DDE command -bool RegisterDDECommand (const char *appName, const char *command, const char *ddeCommand, const char *application) +bool RegisterDDECommand(const char *appName, const char *command, const char *ddeCommand, const char *application) { // Create the app key HKEY hKey; - if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + if (RegCreateKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(appName), &hKey) == ERROR_SUCCESS) { // Create the icon char tmp[512]; - smprintf (tmp, 512, "shell\\%s\\ddeexec", command); - if (RegCreateKey (hKey, tmp, &hKey) == ERROR_SUCCESS) + smprintf(tmp, 512, "shell\\%s\\ddeexec", command); + if (RegCreateKey(hKey, nlUtf8ToTStr(tmp), &hKey) == ERROR_SUCCESS) { // Set the description - RegSetValue (hKey, "", REG_SZ, ddeCommand, strlen (ddeCommand)); + tstring tddeCommand = utf8ToTStr(ddeCommand); + RegSetValue(hKey, _T(""), REG_SZ, tddeCommand.c_str(), (tddeCommand.size() + 1) * sizeof(TCHAR)); HKEY hKey2; - if (RegCreateKey (hKey, "application", &hKey2) == ERROR_SUCCESS) + if (RegCreateKey(hKey, _T("application"), &hKey2) == ERROR_SUCCESS) { - RegSetValue (hKey2, "", REG_SZ, application, strlen (application)); - if (RegCreateKey (hKey, "topic", &hKey2) == ERROR_SUCCESS) + tstring tapplication = utf8ToTStr(application); + RegSetValue(hKey2, _T(""), REG_SZ, tapplication.c_str(), (tapplication.size() + 1) * sizeof(TCHAR)); + if (RegCreateKey(hKey, _T("topic"), &hKey2) == ERROR_SUCCESS) { - RegSetValue (hKey2, "", REG_SZ, "system", strlen ("system")); + RegSetValue(hKey2, _T(""), REG_SZ, _T("system"), (strlen("system") + 1) * sizeof(TCHAR)); return true; } } @@ -163,28 +172,29 @@ bool RegisterDDECommand (const char *appName, const char *command, const char *d } // Register a file extension -bool RegisterShellFileExt (const char *ext, const char *appName) +bool RegisterShellFileExt(const char *ext, const char *appName) { // Remove key in explorer registry if exist HKEY hKey; - string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\"+string (ext); - deleteKey (HKEY_CURRENT_USER, key.c_str ()); + string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\" + string(ext); + deleteKey(HKEY_CURRENT_USER, nlUtf8ToTStr(key)); // Create the app key - if (RegCreateKey (HKEY_CLASSES_ROOT, ext, &hKey) == ERROR_SUCCESS) + if (RegCreateKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(ext), &hKey) == ERROR_SUCCESS) { // Set the description - RegSetValue (hKey, "", REG_SZ, appName, strlen (appName)); + tstring tAppName = utf8ToTStr(appName); + RegSetValue(hKey, _T(""), REG_SZ, tAppName.c_str(), (tAppName.size() + 1) * sizeof(TCHAR)); return true; } return false; } // Register a file extension -bool UnregisterShellFileExt (const char *ext) +bool UnregisterShellFileExt(const char *ext) { // Delete the app key - if (RegDeleteKey (HKEY_CLASSES_ROOT, ext) == ERROR_SUCCESS) + if (RegDeleteKey(HKEY_CLASSES_ROOT, nlUtf8ToTStr(ext)) == ERROR_SUCCESS) { return true; } diff --git a/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp index e57888595..a77b9604a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -103,13 +106,13 @@ void CSettingsDialog::OnOK() UpdateData (); // Make a config file - theApp.RootSearchPath = RootSearchPath; - theApp.TypeDfnSubDirectory = TypeDfnSubDirectory; + theApp.RootSearchPath = NLMISC::tStrToUtf8(RootSearchPath); + theApp.TypeDfnSubDirectory = NLMISC::tStrToUtf8(TypeDfnSubDirectory); theApp.RememberListSize = RememberListSize; theApp.StartExpanded = StartExpanded ? TRUE : FALSE; theApp.MaxUndo = MaxUndo; - theApp.DefaultDfn = DefaultDfn; - theApp.DefaultType = DefaultType; + theApp.DefaultDfn = NLMISC::tStrToUtf8(DefaultDfn); + theApp.DefaultType = NLMISC::tStrToUtf8(DefaultType); theApp.saveCfg (); theApp.initCfg (); @@ -118,30 +121,30 @@ void CSettingsDialog::OnOK() void CSettingsDialog::OnBrowse() { - UpdateData (); - + UpdateData(); + // Select a directory. - char path[MAX_PATH]; + TCHAR path[MAX_PATH]; // Build the struct BROWSEINFO info; - memset (&info, 0, sizeof (BROWSEINFO)); - info.lpszTitle="Select the root search directory"; - info.ulFlags=BIF_RETURNONLYFSDIRS; + memset(&info, 0, sizeof(BROWSEINFO)); + info.lpszTitle = _T("Select the root search directory"); + info.ulFlags = BIF_RETURNONLYFSDIRS; // Select the path LPITEMIDLIST list; - if (list=SHBrowseForFolder (&info)) + if (list = SHBrowseForFolder(&info)) { // Convert item into path string - BOOL bRet=SHGetPathFromIDList(list, path); + BOOL bRet = SHGetPathFromIDList(list, path); if (bRet) { // Set the path RootSearchPath = path; } - } - UpdateData (FALSE); + } + UpdateData(FALSE); } void CSettingsDialog::OnChangeRememberListSize() diff --git a/code/ryzom/tools/leveldesign/georges_dll/stdafx.h b/code/ryzom/tools/leveldesign/georges_dll/stdafx.h index 91a0d1f9a..1ac7df3e3 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/stdafx.h +++ b/code/ryzom/tools/leveldesign/georges_dll/stdafx.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -26,8 +29,13 @@ #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp index 53698ea8f..291fee2ca 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -88,7 +91,7 @@ BOOL CTypeDialog::OnInitDialog() // Create the type combo setStaticSize (currentPos); - LabelType.Create ("Type:", WS_VISIBLE, currentPos, this); + LabelType.Create (_T("Type:"), WS_VISIBLE, currentPos, this); initWidget (LabelType); getNextPosLabel (currentPos); @@ -101,7 +104,7 @@ BOOL CTypeDialog::OnInitDialog() uint item; ComboType.ResetContent (); for (item=0; itemGetDocument (); + CGeorgesEditDoc *doc = View->GetDocument(); if (doc) { - CGeorgesEditDocSub *current = doc->getSelectedObject (); + CGeorgesEditDocSub *current = doc->getSelectedObject(); if (current) { CString str; - Default.UpdateData (); - Default.GetWindowText (str); + Default.UpdateData(); + Default.GetWindowText(str); - doc->modify (new CActionString (IAction::TypeDefault, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); + doc->modify(new CActionString(IAction::TypeDefault, nlTStrToUtf8(str), *doc, "", "", + doc->getLeftView()->getCurrentSelectionId(), 0)); } } } void CTypeDialog::setMinToDocument () { - CGeorgesEditDoc *doc = View->GetDocument (); + CGeorgesEditDoc *doc = View->GetDocument(); if (doc) { - CGeorgesEditDocSub *current = doc->getSelectedObject (); + CGeorgesEditDocSub *current = doc->getSelectedObject(); if (current) { CString str; - Min.UpdateData (); - Min.GetWindowText (str); + Min.UpdateData(); + Min.GetWindowText(str); - doc->modify (new CActionString (IAction::TypeMin, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); + doc->modify(new CActionString(IAction::TypeMin, nlTStrToUtf8(str), *doc, "", "", + doc->getLeftView()->getCurrentSelectionId(), 0)); } } } -void CTypeDialog::setMaxToDocument () +void CTypeDialog::setMaxToDocument() { - CGeorgesEditDoc *doc = View->GetDocument (); + CGeorgesEditDoc *doc = View->GetDocument(); if (doc) { - CGeorgesEditDocSub *current = doc->getSelectedObject (); + CGeorgesEditDocSub *current = doc->getSelectedObject(); CString str; - Max.UpdateData (); - Max.GetWindowText (str); + Max.UpdateData(); + Max.GetWindowText(str); - doc->modify (new CActionString (IAction::TypeMax, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); + doc->modify(new CActionString(IAction::TypeMax, nlTStrToUtf8(str), *doc, "", "", + doc->getLeftView()->getCurrentSelectionId(), 0)); } } -void CTypeDialog::setIncrementToDocument () +void CTypeDialog::setIncrementToDocument() { - CGeorgesEditDoc *doc = View->GetDocument (); + CGeorgesEditDoc *doc = View->GetDocument(); if (doc) { - CGeorgesEditDocSub *current = doc->getSelectedObject (); + CGeorgesEditDocSub *current = doc->getSelectedObject(); CString str; - Increment.UpdateData (); - Increment.GetWindowText (str); + Increment.UpdateData(); + Increment.GetWindowText(str); - doc->modify (new CActionString (IAction::TypeIncrement, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); + doc->modify(new CActionString(IAction::TypeIncrement, nlTStrToUtf8(str), *doc, "", "", + doc->getLeftView()->getCurrentSelectionId(), 0)); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/version.rc2 b/code/ryzom/tools/leveldesign/georges_dll/version.rc2 new file mode 100644 index 000000000..450a9414d --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_dll/version.rc2 @@ -0,0 +1,62 @@ + +#ifndef NL_VERSION_RC2 +#define NL_VERSION_RC2 + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL +#pragma code_page(65001) + +#include +#include "config.h" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "_r" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Georges Edit dynamic library" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "georges" NL_FILEEXT ".dll" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About Georges Edit" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT NL_VERSION,IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT COPYRIGHT,IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP +END + +#endif /* #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) */ +#endif /* #ifndef NL_VERSION_RC2 */ diff --git a/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt index 07ac799c9..96b0a99f5 100644 --- a/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt @@ -1,12 +1,14 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.rc *.rc2) + +SOURCE_GROUP("" FILES ${SRC}) ADD_DEFINITIONS(${MFC_DEFINITIONS}) SET(CMAKE_MFC_FLAG 2) -ADD_EXECUTABLE(georges_exe WIN32 ${SRC} georges_exe.rc) +ADD_EXECUTABLE(georges WIN32 ${SRC}) -TARGET_LINK_LIBRARIES(georges_exe nelmisc nelgeorges georges_dll) +TARGET_LINK_LIBRARIES(georges nelmisc nelgeorges georges_dll) -NL_DEFAULT_PROPS(georges_exe "Ryzom, Tools, Georges: Georges Exe") -NL_ADD_RUNTIME_FLAGS(georges_exe) +NL_DEFAULT_PROPS(georges "Ryzom, Tools, Georges: Georges Exe") +NL_ADD_RUNTIME_FLAGS(georges) -INSTALL(TARGETS georges_exe RUNTIME DESTINATION ${RYZOM_BIN_PREFIX} COMPONENT tools) +INSTALL(TARGETS georges RUNTIME DESTINATION ${RYZOM_BIN_PREFIX} COMPONENT tools) diff --git a/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp b/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp index 864a74bd7..fe580e1c4 100644 --- a/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp +++ b/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -31,11 +34,7 @@ using namespace std; - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) +int APIENTRY nltWinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPTSTR lpCmdLine, int nCmdShow) { // Init the NeL application context NLMISC::CApplicationContext context; @@ -48,7 +47,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, // Init ui pGeorges->initUI(nCmdShow, true); - string cmd = lpCmdLine; + string cmd = NLMISC::tStrToUtf8(lpCmdLine); if(!cmd.empty()) { nlinfo("Using command line '%s'", cmd.c_str()); diff --git a/code/ryzom/tools/leveldesign/georges_exe/georges_exe.rc b/code/ryzom/tools/leveldesign/georges_exe/georges_exe.rc index b2d0d350a..17323ea94 100644 --- a/code/ryzom/tools/leveldesign/georges_exe/georges_exe.rc +++ b/code/ryzom/tools/leveldesign/georges_exe/georges_exe.rc @@ -13,11 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// English resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL #pragma code_page(1252) #endif //_WIN32 @@ -52,13 +52,13 @@ END 3 TEXTINCLUDE DISCARDABLE BEGIN - "\r\n" + "#include ""version.rc2""\r\n" "\0" END #endif // APSTUDIO_INVOKED -#endif // English (U.S.) resources +#endif // English resources ///////////////////////////////////////////////////////////////////////////// @@ -68,7 +68,7 @@ END // // Generated from the TEXTINCLUDE 3 resource. // - +#include "version.rc2" ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/code/ryzom/tools/leveldesign/georges_exe/version.rc2 b/code/ryzom/tools/leveldesign/georges_exe/version.rc2 new file mode 100644 index 000000000..2fd036bc9 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_exe/version.rc2 @@ -0,0 +1,51 @@ + +#ifndef NL_VERSION_RC2 +#define NL_VERSION_RC2 + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL +#pragma code_page(65001) + +#include +#include "config.h" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Georges Edit" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "georges" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +#endif /* #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) */ +#endif /* #ifndef NL_VERSION_RC2 */ diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h index 16449a4d3..0b19077c4 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.cpp index 8b9092b4c..23a447850 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -191,11 +194,11 @@ BOOL CPageBgFades::OnInitDialog() for (uint i =0; i<32; ++i) { char tmp[128]; - GetDlgItem(FILTER_NAMES[i])->SetWindowText(SoundDialog->EnvNames[i].Name.c_str()); - sprintf(tmp, "%u", SoundDialog->FilterFades.FadeIns[i]); - GetDlgItem(FILTER_FADE_IN[i])->SetWindowText(tmp); - sprintf(tmp, "%u", SoundDialog->FilterFades.FadeOuts[i]); - GetDlgItem(FILTER_FADE_OUT[i])->SetWindowText(tmp); + GetDlgItem(FILTER_NAMES[i])->SetWindowText(nlUtf8ToTStr(SoundDialog->EnvNames[i].Name)); + sprintf(tmp, "%u", (unsigned int)SoundDialog->FilterFades.FadeIns[i]); + GetDlgItem(FILTER_FADE_IN[i])->SetWindowText(nlUtf8ToTStr(tmp)); + sprintf(tmp, "%u", (unsigned int)SoundDialog->FilterFades.FadeOuts[i]); + GetDlgItem(FILTER_FADE_OUT[i])->SetWindowText(nlUtf8ToTStr(tmp)); } SoundDialog->getSoundPlugin()->getMixer()->setBackgroundFilterFades(SoundDialog->FilterFades); @@ -209,20 +212,20 @@ BOOL CPageBgFades::OnCommand(WPARAM wParam, LPARAM lParam) if (lParam != 0 && HIWORD(wParam) == EN_CHANGE) { int id = ::GetDlgCtrlID(HWND(lParam)); - char tmp[1024]; + TCHAR tmp[1024]; if (FILTER_FADE_IN_IDX.find(id) != FILTER_FADE_IN_IDX.end()) { // this is a fade in value modified ! GetDlgItem(id)->GetWindowText(tmp, 1024); - SoundDialog->FilterFades.FadeIns[FILTER_FADE_IN_IDX[id]] = atoi(tmp); + SoundDialog->FilterFades.FadeIns[FILTER_FADE_IN_IDX[id]] = atoi(nlTStrToUtf8(tmp)); SoundDialog->getSoundPlugin()->getMixer()->setBackgroundFilterFades(SoundDialog->FilterFades); } else if (FILTER_FADE_OUT_IDX.find(id) != FILTER_FADE_OUT_IDX.end()) { // this is a fade in value modified ! GetDlgItem(id)->GetWindowText(tmp, 1024); - SoundDialog->FilterFades.FadeOuts[FILTER_FADE_OUT_IDX[id]] = atoi(tmp); + SoundDialog->FilterFades.FadeOuts[FILTER_FADE_OUT_IDX[id]] = atoi(nlTStrToUtf8(tmp)); SoundDialog->getSoundPlugin()->getMixer()->setBackgroundFilterFades(SoundDialog->FilterFades); } } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.cpp index 239c5b370..153f4aad0 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -421,8 +424,8 @@ BOOL CPageBgFlags::OnInitDialog() const NLSOUND::UAudioMixer::TBackgroundFlags &flag = SoundDialog->getSoundPlugin()->getMixer()->getBackgroundFlags(); for (uint i=0; i<32; ++i) { - GetDlgItem(FILTER_EDIT_NAME[i])->SetWindowText(SoundDialog->EnvNames[i].Name.c_str()); - GetDlgItem(FILTER_SIM_NAME[i])->SetWindowText(SoundDialog->EnvNames[i].ShortName.c_str()); + GetDlgItem(FILTER_EDIT_NAME[i])->SetWindowText(nlUtf8ToTStr(SoundDialog->EnvNames[i].Name)); + GetDlgItem(FILTER_SIM_NAME[i])->SetWindowText(nlUtf8ToTStr(SoundDialog->EnvNames[i].ShortName)); static_cast(GetDlgItem(FILTER_SIM[i]))->SetCheck(flag.Flags[i] ? 1 : 0); } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h index 74eb65e07..cb3d3bf8e 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.cpp index b3add5365..e7efc8f7c 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -95,9 +98,9 @@ BOOL CPageComtext::OnCommand(WPARAM wParam, LPARAM lParam) if (EDIT_ARG_IDX.find(id) != EDIT_ARG_IDX.end()) { // need to update the var. - char tmp[1024]; + TCHAR tmp[1024]; GetDlgItem(id)->GetWindowText(tmp, 1024); - SoundContext.Args[EDIT_ARG_IDX[id]] = atoi(tmp); + SoundContext.Args[EDIT_ARG_IDX[id]] = atoi(nlTStrToUtf8(tmp)); } } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/georges_plugin_sound.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/georges_plugin_sound.cpp index dd76b9f9e..047e8df6a 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/georges_plugin_sound.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/georges_plugin_sound.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -49,14 +52,13 @@ __declspec( dllexport ) IEditPlugin *IGeorgesEditGetInterface (int version, NLGE } catch (const std::exception &e) { - string reason = e.what(); - MessageBox (NULL, reason.c_str(), "Sound plugin", MB_OK); + MessageBox (NULL, nlUtf8ToTStr(e.what()), _T("Sound plugin"), MB_OK); return NULL; } } else { - MessageBox (NULL, "Plugin version invalid.", "Sound plugin for georges editor", MB_OK|MB_ICONEXCLAMATION); + MessageBox (NULL, _T("Plugin version invalid."), _T("Sound plugin for georges editor"), MB_OK|MB_ICONEXCLAMATION); return NULL; } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/listener_view.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/listener_view.cpp index 78d8d0ce8..4883b1b25 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/listener_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/listener_view.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -68,7 +71,7 @@ bool CListenerView::registerClass() } catch (CResourceException* e) { - AfxMessageBox("Couldn't register class! (Already registered?)"); + AfxMessageBox(_T("Couldn't register class! (Already registered?)")); e->Delete(); return false; } @@ -80,7 +83,7 @@ bool CListenerView::registerClass() _VolumeCurve.CreatePen(PS_SOLID, 1, RGB(255, 0, 128)); _Font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial"); + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); return true; } @@ -99,7 +102,7 @@ void CListenerView::init(CSoundPlugin* plugin, CRect& rect, CWnd* parent) _OuterAngle = 360; _InnerAngle = 360; - if (!Create((LPCTSTR) _WndClass, "Listener", WS_CHILD | WS_VISIBLE, rect, parent, ++_WndId)) + if (!Create((LPCTSTR) _WndClass, _T("Listener"), WS_CHILD | WS_VISIBLE, rect, parent, ++_WndId)) { throw exception("failed to create the listener view"); } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/loading_dialog.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/loading_dialog.h index c21df7c2d..5f81f13ce 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/loading_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/loading_dialog.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.cpp index 58ea1e9da..741b702ac 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -239,7 +242,7 @@ void CSoundDialog::displayTime(uint32 msec) uint min = sec / 60; sec -= min * 60; _snprintf(s, 256, "%02d:%02d", min, sec); - GetDlgItem(IDC_TIME)->SetWindowText(s); + GetDlgItem(IDC_TIME)->SetWindowText(nlUtf8ToTStr(s)); } // *************************************************************************** @@ -285,7 +288,7 @@ void CSoundDialog::updateInfo() CPageBase::docChanged(); - SetWindowText(_Name.c_str()); + SetWindowText(nlUtf8ToTStr(_Name)); char s[256]; /* if (_Filename.empty()) @@ -342,7 +345,7 @@ void CSoundDialog::updateInfo() msec -= sec * 1000; sec -= min * 60; _snprintf(s, 256, "%02d:%02d.%03d", min, sec, msec); - GetDlgItem(IDC_DURATION)->SetWindowText(s); + GetDlgItem(IDC_DURATION)->SetWindowText(nlUtf8ToTStr(s)); updateButton(); } @@ -361,7 +364,7 @@ bool CSoundDialog::getFileInfo(string& filename, uint& sampleRate, uint& sampleS } // Open the file - HMMIO hmmio = mmioOpen((char*) path.c_str(), NULL, MMIO_READ | MMIO_DENYWRITE); + HMMIO hmmio = mmioOpen((LPTSTR)nlUtf8ToTStr(path), NULL, MMIO_READ | MMIO_DENYWRITE); if (hmmio == NULL) { return false; @@ -484,7 +487,7 @@ void CSoundDialog::OnControlPlayback() if (str == "*.sound") { - MessageBox("You must save the file before playing it !", "Warning"); + MessageBox(_T("You must save the file before playing it !"), _T("Warning")); return; } } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.h index 12b1a6ac8..f056dd755 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_dialog.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp index e7c6b844c..6196f6fca 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -68,9 +71,6 @@ CSoundPlugin::CSoundPlugin(IEdit *globalInterface) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - // Initialize without sheet id bin - NLMISC::CSheetId::initWithoutSheet(); - CVector dir; _GlobalInterface = globalInterface; @@ -340,7 +340,7 @@ void CSoundPlugin::setActiveDocument(IEditDocument *pdoc) _Dialog.setName(_Filename); // 1st, try to found the sound in the preloaded sound bank. - _Sound = _Mixer->getSoundId(CSheetId(_Filename, "sound")); + _Sound = _Mixer->getSoundId(CStringMapper::map(_Filename)); if (_Sound == NULL) { // not found, create a new one. @@ -362,7 +362,7 @@ void CSoundPlugin::setActiveDocument(IEditDocument *pdoc) if (invalid && !_InvalidSound) { - MessageBox(NULL, "This sound contains an infinite recursion !", "Sound Error", MB_ICONERROR); + MessageBox(NULL, _T("This sound contains an infinite recursion !"), _T("Sound Error"), MB_ICONERROR); } // pre-create the sound to force loading any missing sample bank (thus avoiding unwanted message box) @@ -410,7 +410,7 @@ void CSoundPlugin::setActiveDocument(IEditDocument *pdoc) message += (*first)+"\n"; } - MessageBox(NULL, message.c_str(), "Sound incomplete", MB_ICONWARNING); + MessageBox(NULL, nlUtf8ToTStr(message), _T("Sound incomplete"), MB_ICONWARNING); } @@ -474,12 +474,12 @@ void CSoundPlugin::onCreateDocument(IEditDocument *document) void CSoundPlugin::createNew() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - char BASED_CODE szFilter[] = "Sound (*.sound)|*.sound|All Files (*.*)|*.*||"; - CFileDialog fileDlg(FALSE, ".sound", "*.sound", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); + TCHAR BASED_CODE szFilter[] = _T("Sound (*.sound)|*.sound|All Files (*.*)|*.*||"); + CFileDialog fileDlg(FALSE, _T(".sound"), _T("*.sound"), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter); if (fileDlg.DoModal() == IDOK) { - string filename = (const char*) fileDlg.GetPathName(); + string filename = NLMISC::tStrToUtf8(fileDlg.GetPathName()); _GlobalInterface->createDocument("sound.dfn", filename.c_str()); } } @@ -540,7 +540,7 @@ void CSoundPlugin::play(std::string &filename) // point.Name = string("simulation-")+_Sound->getName()+"-000"; region.VPoints.push_back(point); - string name = string("simulation-")+NLMISC::CFile::getFilenameWithoutExtension(_Sound->getName().toString())+"-000"; + string name = string("simulation-")+CStringMapper::unmap(_Sound->getName())+"-000"; if (region.VPoints.back().checkProperty("name")) region.VPoints.back().removePropertyByName("name"); @@ -585,8 +585,7 @@ void CSoundPlugin::play(std::string &filename) } catch (ESoundDriver& e) { - string reason = e.what(); - MessageBox (NULL, reason.c_str(), "Sound plugin", MB_OK); + MessageBox(NULL, nlUtf8ToTStr(e.what()), _T("Sound plugin"), MB_OK); } } diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h index 021749d15..69e3755aa 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2012 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/std_sound_plugin.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/std_sound_plugin.h index 8fb65c948..17c2f0a75 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/std_sound_plugin.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/std_sound_plugin.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -18,8 +21,13 @@ #define STDAFX_H #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/leveldesign/icon_search/icon_search.cpp b/code/ryzom/tools/leveldesign/icon_search/icon_search.cpp index 7d406ec8c..029abcd4f 100644 --- a/code/ryzom/tools/leveldesign/icon_search/icon_search.cpp +++ b/code/ryzom/tools/leveldesign/icon_search/icon_search.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/CMakeLists.txt b/code/ryzom/tools/leveldesign/mission_compiler_fe/CMakeLists.txt index f9321152c..be86f6a50 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/CMakeLists.txt @@ -1,8 +1,10 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.rc *.rc2 res/*.rc2 res/*.ico) + +SOURCE_GROUP("" FILES ${SRC}) ADD_DEFINITIONS(${MFC_DEFINITIONS}) SET(CMAKE_MFC_FLAG 2) -ADD_EXECUTABLE(ryzom_mission_compiler_fe WIN32 ${SRC} mission_compiler_fe.rc) +ADD_EXECUTABLE(ryzom_mission_compiler_fe WIN32 ${SRC}) TARGET_LINK_LIBRARIES(ryzom_mission_compiler_fe nelmisc nelligo ryzom_mission_compiler_lib) diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/Resource.h b/code/ryzom/tools/leveldesign/mission_compiler_fe/Resource.h index 28608ab10..9f7b75159 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/Resource.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/Resource.h @@ -1,21 +1,5 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - //{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. +// Microsoft Visual C++ generated include file. // Used by mission_compiler_fe.rc // #define IDM_ABOUTBOX 0x0010 diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/StdAfx.h b/code/ryzom/tools/leveldesign/mission_compiler_fe/StdAfx.h index b8693c571..8a67516b4 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/StdAfx.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/StdAfx.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -27,8 +30,13 @@ #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.cpp b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.cpp index 9cea31379..b8a82de55 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -79,7 +82,7 @@ BOOL CMissionCompilerFeApp::InitInstance() #endif // look at the command line parameters for command line mode - string cmdLine = m_lpCmdLine; + string cmdLine = NLMISC::tStrToUtf8(m_lpCmdLine); if (cmdLine.find("-c") != string::npos) { NLMISC::createDebug(); diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.rc b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.rc index 64ac8c1d2..812261b50 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.rc +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_fe.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // #include "resource.h" @@ -13,29 +13,18 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// English resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL #pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON_FILTER ICON DISCARDABLE "res\\icon_fil.ico" ///////////////////////////////////////////////////////////////////////////// // // Menu // -IDR_MENU1 MENU DISCARDABLE +IDR_MENU1 MENU BEGIN POPUP "Special" BEGIN @@ -50,89 +39,25 @@ END // Dialog // -IDD_DIALOG_ADD_PATH DIALOG DISCARDABLE 0, 0, 283, 46 -STYLE WS_POPUP | WS_CAPTION +IDD_DIALOG_ADD_PATH DIALOG 0, 0, 283, 46 +STYLE DS_SETFONT | WS_POPUP | WS_CAPTION CAPTION "Init compiler..." FONT 8, "MS Sans Serif" BEGIN - EDITTEXT IDC_ADD_PATH,7,7,269,32,ES_MULTILINE | ES_AUTOVSCROLL | - ES_AUTOHSCROLL | ES_READONLY -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_DIALOG_ADD_PATH, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 276 - TOPMARGIN, 7 - BOTTOMMARGIN, 39 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// French (France) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) -#ifdef _WIN32 -LANGUAGE LANG_FRENCH, SUBLANG_FRENCH -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\mission_compiler_fe.ico" -IDI_ICON_FILTER ICON DISCARDABLE "res\\icon_fil.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "A propos de mission_compiler_fe" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "mission_compiler_fe version 1.0",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Copyright (C) 2004",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP + EDITTEXT IDC_ADD_PATH,7,7,269,32,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY END IDD_MISSION_COMPILER_FE_DIALOG DIALOGEX 0, 0, 361, 322 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "Primitive tool" MENU IDR_MENU1 -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN DEFPUSHBUTTON "&COMPILE",IDC_COMPILE,155,242,50,14,WS_DISABLED PUSHBUTTON "&QUIT",IDCANCEL,156,301,50,14 - LISTBOX IDC_LIST_SRC,7,125,136,190,LBS_SORT | - LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | - WS_HSCROLL | WS_TABSTOP - LISTBOX IDC_LIST_DST,218,113,136,202,LBS_SORT | - LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | - WS_TABSTOP + LISTBOX IDC_LIST_SRC,7,125,136,190,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + LISTBOX IDC_LIST_DST,218,113,136,202,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP CTEXT "Available Primitive files",IDC_STATIC,7,90,136,11 CTEXT "Selected primitive",IDC_STATIC,218,90,136,15 PUSHBUTTON ">>",IDC_ADD,156,128,50,16 @@ -141,49 +66,37 @@ BEGIN PUSHBUTTON "ALL >>",IDC_ADD_ALL,156,146,50,16 EDITTEXT IDC_FILTER,32,104,112,14,ES_AUTOHSCROLL ICON IDI_ICON_FILTER,IDC_STATIC,8,104,21,20,SS_REALSIZEIMAGE - DEFPUSHBUTTON "COMPILE &PUBLISH",IDC_PUBLISH,155,259,50,26, - BS_MULTILINE | WS_DISABLED + DEFPUSHBUTTON "COMPILE &PUBLISH",IDC_PUBLISH,155,259,50,26,BS_MULTILINE | WS_DISABLED PUSHBUTTON "&VALIDATE",IDC_VALIDATE,155,225,50,14,WS_DISABLED EDITTEXT IDC_DATA_DIRECTORY,89,7,265,15,ES_AUTOHSCROLL LTEXT "",IDC_PATH_WARNING,105,28,235,8 - GROUPBOX "Publish to the following servers",IDC_STATIC,62,38,254, - 45 - CONTROL "Server 1",IDC_CHECK_SRV1,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,74,50,41,10 - CONTROL "Server 2",IDC_CHECK_SRV2,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,74,66,41,10 - CONTROL "Server 3",IDC_CHECK_SRV3,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,126,50,41,10 - CONTROL "Server4",IDC_CHECK_SRV4,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,126,66,41,10 - CONTROL "Server 5",IDC_CHECK_SRV5,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,188,50,41,10 - CONTROL "Server 6",IDC_CHECK_SRV6,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,188,66,41,10 - CONTROL "Server 7",IDC_CHECK_SRV7,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,252,50,39,11 - CONTROL "Server 8",IDC_CHECK_SRV8,"Button",BS_AUTOCHECKBOX | - WS_DISABLED | WS_TABSTOP,252,64,42,13 + GROUPBOX "Publish to the following servers",IDC_STATIC,62,38,254,45 + CONTROL "Server 1",IDC_CHECK_SRV1,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,74,50,41,10 + CONTROL "Server 2",IDC_CHECK_SRV2,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,74,66,41,10 + CONTROL "Server 3",IDC_CHECK_SRV3,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,126,50,41,10 + CONTROL "Server4",IDC_CHECK_SRV4,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,126,66,41,10 + CONTROL "Server 5",IDC_CHECK_SRV5,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,188,50,41,10 + CONTROL "Server 6",IDC_CHECK_SRV6,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,188,66,41,10 + CONTROL "Server 7",IDC_CHECK_SRV7,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,252,50,39,11 + CONTROL "Server 8",IDC_CHECK_SRV8,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,252,64,42,13 END -IDD_COMPIL DIALOG DISCARDABLE 0, 0, 294, 178 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION +IDD_COMPIL DIALOG 0, 0, 294, 178 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION CAPTION "Compilation status" FONT 8, "MS Sans Serif" BEGIN - EDITTEXT IDC_COMPIL_LOG,7,7,280,148,ES_MULTILINE | ES_READONLY | - WS_VSCROLL | WS_HSCROLL + EDITTEXT IDC_COMPIL_LOG,7,7,280,148,ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_HSCROLL PUSHBUTTON "Ok",IDOK,228,158,59,16,WS_DISABLED END -IDD_DIALOG_MODE DIALOG DISCARDABLE 0, 0, 155, 76 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +IDD_DIALOG_MODE DIALOG 0, 0, 155, 76 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Choose Tool Mode" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "Compile mission",ID_MODE_COMPILE,7,14,141,23 - PUSHBUTTON "Publish primitive",ID_MODE_PUBLISH,7,46,141,23, - WS_DISABLED + PUSHBUTTON "Publish primitive",ID_MODE_PUBLISH,7,46,141,23,WS_DISABLED END @@ -193,41 +106,29 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE +GUIDELINES DESIGNINFO BEGIN - IDD_ABOUTBOX, DIALOG + IDD_DIALOG_ADD_PATH, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 228 + RIGHTMARGIN, 276 TOPMARGIN, 7 - BOTTOMMARGIN, 48 + BOTTOMMARGIN, 39 END +END +#endif // APSTUDIO_INVOKED - IDD_MISSION_COMPILER_FE_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 354 - TOPMARGIN, 7 - BOTTOMMARGIN, 315 - END - IDD_COMPIL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 287 - TOPMARGIN, 7 - BOTTOMMARGIN, 174 - END +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// - IDD_DIALOG_MODE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 148 - TOPMARGIN, 7 - BOTTOMMARGIN, 69 - END -END -#endif // APSTUDIO_INVOKED +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\red_pill.ico" + +IDI_ICON_FILTER ICON "res\\icon_fil.ico" #ifdef APSTUDIO_INVOKED @@ -236,18 +137,18 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE BEGIN "#define _AFX_NO_SPLITTER_RESOURCES\r\n" "#define _AFX_NO_OLE_RESOURCES\r\n" @@ -262,66 +163,25 @@ BEGIN "#include ""res\\mission_compiler_fe.rc2"" // non-Microsoft Visual C++ edited resources\r\n" "#include ""l.fra\\afxres.rc"" // Standard components\r\n" "#endif\r\n" + "\r\n" + "#include ""version.rc2""\r\n" "\0" END #endif // APSTUDIO_INVOKED -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040C04B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "Application MFC mission_compiler_fe\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "mission_compiler_fe\0" - VALUE "LegalCopyright", "Copyright (C) 2004\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "mission_compiler_fe.EXE\0" - VALUE "ProductName", "Application mission_compiler_fe\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x40c, 1200 - END -END - -#endif // !_MAC - - ///////////////////////////////////////////////////////////////////////////// // // String Table // -STRINGTABLE DISCARDABLE +STRINGTABLE BEGIN - IDS_ABOUTBOX "&A propos de mission_compiler_fe..." + IDS_ABOUTBOX "&About Ryzom Mission Compiler..." END -#endif // French (France) resources +#endif // English resources ///////////////////////////////////////////////////////////////////////////// @@ -345,6 +205,8 @@ LANGUAGE 12, 1 #include "l.fra\afxres.rc" // Standard components #endif +#include "version.rc2" + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp index fdbf9e668..1198d166d 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/mission_compiler_feDlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -184,7 +187,7 @@ BOOL CMissionCompilerFeDlg::OnInitDialog() if (SearchPaths.size() > 1) { CWnd* pWnd = GetDlgItem(IDC_PATH_WARNING); - pWnd->SetWindowText("Warning ! config file contains more than one path ! Only the first is shown ! "); + pWnd->SetWindowText(_T("Warning ! config file contains more than one path ! Only the first is shown ! ")); } UpdateData(FALSE); @@ -196,16 +199,16 @@ BOOL CMissionCompilerFeDlg::OnInitDialog() // Check if the file "tmptool.txt" exists in system temp directory // It's that way world_editor pass arguments to the program // The file contains a list of primitives to select - char tmpPath[MAX_PATH]; - GetEnvironmentVariable("TMP", tmpPath, MAX_PATH); - strcat(tmpPath, "\\tmptool.txt"); + TCHAR tmpPath[MAX_PATH]; + GetEnvironmentVariable(_T ("TMP"), tmpPath, MAX_PATH); + _tcscat(tmpPath, _T("\\tmptool.txt")); - if (NLMISC::CFile::fileExists(tmpPath)) + if (NLMISC::CFile::fileExists(NLMISC::tStrToUtf8(tmpPath))) { - FILE *f = nlfopen(tmpPath, "r"); + FILE *f = _tfopen(tmpPath, _T("r")); if (f == NULL) { - nlinfo("Can't open the file for reading !\n%s", tmpPath); + nlinfo("Can't open the file for reading !\n%s", nlTStrToUtf8(tmpPath)); return TRUE; } @@ -222,7 +225,7 @@ BOOL CMissionCompilerFeDlg::OnInitDialog() fclose(f); // delete temp file - NLMISC::CFile::deleteFile(tmpPath); + NLMISC::CFile::deleteFile(NLMISC::tStrToUtf8(tmpPath)); // Test to check if the primitive is in src list // If it is, erase it form src and add it to dest @@ -240,8 +243,8 @@ BOOL CMissionCompilerFeDlg::OnInitDialog() files[i] = toUpper(CPath::standardizeDosPath(files[i])); if (srcPath != files[i]) { - ::MessageBox(NULL, "Primitive path and working directory are not the same !", - "Mission compiler", MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, _T("Primitive path and working directory are not the same !"), + _T("Mission compiler"), MB_OK|MB_ICONEXCLAMATION); } else { @@ -252,8 +255,8 @@ BOOL CMissionCompilerFeDlg::OnInitDialog() else { char buffer[1024]; - sprintf(buffer, "Can't find primitive in the directory !\n%s\n", files[i].c_str(), m_dataDirectory); - ::MessageBox(NULL, buffer, "Mission compiler", MB_OK|MB_ICONEXCLAMATION); + sprintf(buffer, "Can't find primitive in the directory !\n%s\n", files[i].c_str(), nlTStrToUtf8(m_dataDirectory)); + ::MessageBox(NULL, nlUtf8ToTStr(buffer), _T("Mission compiler"), MB_OK|MB_ICONEXCLAMATION); } } @@ -274,7 +277,7 @@ void CMissionCompilerFeDlg::fillSourceList() addPath.CenterWindow(); addPath.ShowWindow(SW_SHOW); - string log(addPath.m_addPathLog); + string log = tStrToUtf8(addPath.m_addPathLog); log += "Reading config file\r\n"; addPath.m_addPathLog = log.c_str(); addPath.UpdateData(FALSE); @@ -283,7 +286,7 @@ void CMissionCompilerFeDlg::fillSourceList() // Fill the src list with available primitives for (uint i=0; iasString(); else { - AfxMessageBox("Can't find configuration var 'ligo_config', fatal", MB_OK); + AfxMessageBox(_T("Can't find configuration var 'ligo_config', fatal"), MB_OK); PostQuitMessage(-1); return false; } @@ -383,7 +386,7 @@ bool CMissionCompilerFeDlg::readConfigFile() { CWnd* pWnd = GetDlgItem(IDC_CHECK_SRV1 + i); pWnd->EnableWindow(TRUE); - pWnd->SetWindowText(names->asString(i).c_str()); + pWnd->SetWindowText(nlUtf8ToTStr(names->asString(i))); ServerName.push_back(names->asString(i)); ServerPathPrim.push_back(pathsPrim->asString(i)); @@ -412,15 +415,15 @@ void CMissionCompilerFeDlg::updateFileList() for (uint i=0; first != last; ++first) { if (m_filter.GetLength() == 0) - m_listSrc.InsertString(i++, first->first.c_str()); + m_listSrc.InsertString(i++, nlUtf8ToTStr(first->first)); else { // check the filter - string filter(m_filter.LockBuffer()); + string filter = tStrToUtf8(m_filter.LockBuffer()); m_filter.UnlockBuffer(); if (first->first.find(filter) != string::npos) - m_listSrc.InsertString(i++, first->first.c_str()); + m_listSrc.InsertString(i++, nlUtf8ToTStr(first->first)); } } } @@ -429,7 +432,7 @@ void CMissionCompilerFeDlg::updateFileList() TFileList::iterator first(_DstList.begin()), last(_DstList.end()); for (uint i=0; first != last; ++first,++i) { - m_listDst.InsertString(i, first->first.c_str()); + m_listDst.InsertString(i, nlUtf8ToTStr(first->first)); } } } @@ -493,7 +496,7 @@ void CMissionCompilerFeDlg::compile(BOOL publish) dlg.UpdateData(FALSE); // dlg.m_compileLogCtrl.SetSel(compileLog.size(), compileLog.size(), FALSE); dlg.RedrawWindow(); - AfxMessageBox(msg.c_str()); + AfxMessageBox(nlUtf8ToTStr(msg)); break; } } @@ -569,7 +572,7 @@ void CMissionCompilerFeDlg::OnAdd() { CString tmp; m_listSrc.GetText(sel[i], tmp); - string file(tmp.LockBuffer()); + string file = tStrToUtf8(tmp.LockBuffer()); tmp.UnlockBuffer(); _DstList.insert(make_pair(file, _SrcList[file])); _SrcList.erase(file); @@ -585,7 +588,7 @@ void CMissionCompilerFeDlg::OnAddAll() { CString tmp; m_listSrc.GetText(0, tmp); - string file(tmp.LockBuffer()); + string file = tStrToUtf8(tmp.LockBuffer()); tmp.UnlockBuffer(); _DstList.insert(make_pair(file, _SrcList[file])); @@ -608,7 +611,7 @@ void CMissionCompilerFeDlg::OnRemove() { CString tmp; m_listDst.GetText(sel[i], tmp); - string file(tmp.LockBuffer()); + string file = tStrToUtf8(tmp.LockBuffer()); tmp.UnlockBuffer(); _SrcList.insert(make_pair(file, _DstList[file])); _DstList.erase(file); @@ -662,7 +665,7 @@ void CMissionCompilerFeDlg::OnSpecialRuncompilertest() CMissionCompiler mc; if (!mc.compileMissions(primDoc.RootNode, sourceDocName)) { - AfxMessageBox("Error while compiling the test primitive, correct error(s) first"); + AfxMessageBox(_T("Error while compiling the test primitive, correct error(s) first")); return; } TMissionDataPtr testMission = mc.getMission(0); @@ -699,7 +702,7 @@ void CMissionCompilerFeDlg::OnSpecialRuncompilertest() { string msg = "In primitive "; msg += buildPrimPath(e.Primitive) + ": " + e.Why; - AfxMessageBox(utf8ToTStr(msg)); + AfxMessageBox(nlUtf8ToTStr(msg)); } } @@ -991,21 +994,21 @@ void CMissionCompilerFeDlg::OnChangeDir() // open a dialog to choose a directory BROWSEINFO bi; - char str[MAX_PATH]; - ITEMIDLIST* pidl; - char sTemp[1024]; + TCHAR str[MAX_PATH]; + LPITEMIDLIST pidl; + TCHAR sTemp[1024]; // fill the structure with options bi.hwndOwner = this->m_hWnd; bi.pidlRoot = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = sTemp; - bi.lpszTitle = "Choose the data directory"; + bi.lpszTitle = _T("Choose the data directory"); bi.ulFlags = 0; bi.lpfn = dataDirBrowseCallbackProc; - char sDir[512]; - strcpy(sDir, m_dataDirectory); + TCHAR sDir[512]; + _tcscpy(sDir, m_dataDirectory); bi.lParam = (LPARAM)sDir; bi.iImage = 0; pidl = SHBrowseForFolder (&bi); @@ -1013,7 +1016,7 @@ void CMissionCompilerFeDlg::OnChangeDir() if (SHGetPathFromIDList(pidl, str)) { m_dataDirectory = str; - SearchPaths[0] = str; + SearchPaths[0] = tStrToUtf8(str); fillSourceList(); updateFileList(); UpdateData(FALSE); @@ -1023,7 +1026,7 @@ void CMissionCompilerFeDlg::OnChangeDir() void CMissionCompilerFeDlg::OnChangeDataDir() { UpdateData(TRUE); - SearchPaths[0] = m_dataDirectory; + SearchPaths[0] = tStrToUtf8(m_dataDirectory); fillSourceList(); updateFileList(); UpdateData(FALSE); diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/res/mission_compiler_fe.ico b/code/ryzom/tools/leveldesign/mission_compiler_fe/res/mission_compiler_fe.ico deleted file mode 100644 index 7eef0bcbe..000000000 Binary files a/code/ryzom/tools/leveldesign/mission_compiler_fe/res/mission_compiler_fe.ico and /dev/null differ diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/res/red_pill.ico b/code/ryzom/tools/leveldesign/mission_compiler_fe/res/red_pill.ico new file mode 100644 index 000000000..c5f250583 Binary files /dev/null and b/code/ryzom/tools/leveldesign/mission_compiler_fe/res/red_pill.ico differ diff --git a/code/ryzom/tools/leveldesign/mission_compiler_fe/version.rc2 b/code/ryzom/tools/leveldesign/mission_compiler_fe/version.rc2 new file mode 100644 index 000000000..46d1c9fae --- /dev/null +++ b/code/ryzom/tools/leveldesign/mission_compiler_fe/version.rc2 @@ -0,0 +1,62 @@ + +#ifndef NL_VERSION_RC2 +#define NL_VERSION_RC2 + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL +#pragma code_page(65001) + +#include +#include "config.h" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Mission Compiler Frontend" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "ryzom_mission_compiler_fe" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About Ryzom Mission Compiler Frontend" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT NL_VERSION,IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT COPYRIGHT,IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP +END + +#endif /* #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) */ +#endif /* #ifndef NL_VERSION_RC2 */ diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp index 28d895f54..b664bb0e2 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2011 Matt RAYKOWSKI (sfb) +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h index 7016bd092..b5f0dbf79 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2011 Fabien HENON +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h index 24f80a19a..4a0ecb958 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2011 Fabien HENON +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp index 5ec77ceb9..8a3daa1d5 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2011 Fabien HENON +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp index 613621ca8..5e627bfa0 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2011 Matt RAYKOWSKI (sfb) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/variables.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/variables.cpp index f27f2a974..9fe80c878 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/variables.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/variables.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2013 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/mp_generator/main.cpp b/code/ryzom/tools/leveldesign/mp_generator/main.cpp index 353642ac6..150807f5c 100644 --- a/code/ryzom/tools/leveldesign/mp_generator/main.cpp +++ b/code/ryzom/tools/leveldesign/mp_generator/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2012 Matt RAYKOWSKI (sfb) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -304,6 +307,11 @@ bool endsWith( const CSString& s, const CSString& substring ) return (s.right( (uint)substring.size() ) == substring); } +bool endsWith( const CSString& s, const char *substring ) +{ + return endsWith(s, CSString(substring)); +} + // Generate item names void GenerateItemNames( const CSString& nomMP, char eco, int level, bool mission, bool creature, CSString& outStr ) diff --git a/code/ryzom/tools/leveldesign/prim_export/CMakeLists.txt b/code/ryzom/tools/leveldesign/prim_export/CMakeLists.txt index 8fbd3912e..4902ee92b 100644 --- a/code/ryzom/tools/leveldesign/prim_export/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/prim_export/CMakeLists.txt @@ -1,4 +1,6 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.rc) + +SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(prim_export ${SRC}) diff --git a/code/ryzom/tools/leveldesign/prim_export/blue_pill.ico b/code/ryzom/tools/leveldesign/prim_export/blue_pill.ico new file mode 100644 index 000000000..269907ec3 Binary files /dev/null and b/code/ryzom/tools/leveldesign/prim_export/blue_pill.ico differ diff --git a/code/ryzom/tools/leveldesign/prim_export/main.cpp b/code/ryzom/tools/leveldesign/prim_export/main.cpp index be875b350..ad78325d5 100644 --- a/code/ryzom/tools/leveldesign/prim_export/main.cpp +++ b/code/ryzom/tools/leveldesign/prim_export/main.cpp @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2010-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/prim_export/main.rc b/code/ryzom/tools/leveldesign/prim_export/main.rc new file mode 100644 index 000000000..a7683d96a --- /dev/null +++ b/code/ryzom/tools/leveldesign/prim_export/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "blue_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Prim Export" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "prim_export" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/land_export/CMakeLists.txt index e1f7fe88c..f51b470db 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/world_editor/land_export/CMakeLists.txt @@ -1,4 +1,6 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.rc) + +SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(land_export ${SRC}) diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export/blue_pill.ico b/code/ryzom/tools/leveldesign/world_editor/land_export/blue_pill.ico new file mode 100644 index 000000000..269907ec3 Binary files /dev/null and b/code/ryzom/tools/leveldesign/world_editor/land_export/blue_pill.ico differ diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp b/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp index 87c4c8448..205002417 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/land_export/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export/main.rc b/code/ryzom/tools/leveldesign/world_editor/land_export/main.rc new file mode 100644 index 000000000..879fa8040 --- /dev/null +++ b/code/ryzom/tools/leveldesign/world_editor/land_export/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "blue_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Land Export" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "land_export" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp index 5ca22a303..319925584 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.cpp @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h index 63fc35dde..a8a6b93cb 100644 --- a/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h +++ b/code/ryzom/tools/leveldesign/world_editor/land_export_lib/export.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/world_editor/CMakeLists.txt index c7258d869..d6eb6c304 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/CMakeLists.txt @@ -1,4 +1,6 @@ -FILE(GLOB SRC *.cpp *.h) +FILE(GLOB SRC *.cpp *.h *.rc *.rc2) + +SOURCE_GROUP("" FILES ${SRC}) LIST(REMOVE_ITEM SRC ${CMAKE_CURRENT_SOURCE_DIR}/export_cb_dlg.cpp ${CMAKE_CURRENT_SOURCE_DIR}/builder_logic.cpp) @@ -6,12 +8,10 @@ ENABLE_LANGUAGE(RC) ADD_DEFINITIONS(${MFC_DEFINITIONS}) SET(CMAKE_MFC_FLAG 2) -ADD_EXECUTABLE(world_editor WIN32 ${SRC} world_editor.rc) +ADD_EXECUTABLE(world_editor WIN32 ${SRC}) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) -SOURCE_GROUP(Resources FILES world_editor.rc) - TARGET_LINK_LIBRARIES(world_editor nelmisc nelligo diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp index c380db296..65cb98af6 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/builder_zone.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -130,10 +133,10 @@ bool CDataBase::init (const string &Path, CZoneBank &zb) string sDirBackup = NLMISC::CPath::getCurrentPath(); // "Path" can be relative to the doc path so we have to be first in the doc path - string s2 = NLMISC::CFile::getPath (tStrToUtf8(getMainFrame()->getDocument()->GetPathName())); + string s2 = NLMISC::CFile::getPath(NLMISC::tStrToUtf8(getMainFrame()->getDocument()->GetPathName())); NLMISC::CPath::setCurrentPath(s2.c_str()); string ss = NLMISC::CPath::getFullPath(Path); - NLMISC::CPath::setCurrentPath (ss.c_str()); + NLMISC::CPath::setCurrentPath(ss.c_str()); uint32 i, m, n, o, p; uint8 k, l; @@ -623,7 +626,7 @@ bool CBuilderZone::refresh () { unload (_ZoneRegionSelected); std::string msg = NLMISC::toString("Cannot add this zone :\n%s", error.c_str()); - MessageBox (NULL, utf8ToTStr(msg), _T("Error"), MB_ICONERROR|MB_OK); + MessageBox (NULL, nlUtf8ToTStr(msg), _T("Error"), MB_ICONERROR|MB_OK); return false; } @@ -1600,25 +1603,25 @@ bool CBuilderZone::initZoneBank (const string &sPathName) { // TODO: replace by NeL methods TCHAR sDirBackup[512]; - GetCurrentDirectory (512, sDirBackup); - SetCurrentDirectory (utf8ToTStr(sPathName)); + GetCurrentDirectory(512, sDirBackup); + SetCurrentDirectory(nlUtf8ToTStr(sPathName)); WIN32_FIND_DATA findData; HANDLE hFind; - hFind = FindFirstFile (_T("*.ligozone"), &findData); - + hFind = FindFirstFile(_T("*.ligozone"), &findData); + while (hFind != INVALID_HANDLE_VALUE) { // If the name of the file is not . or .. then its a valid entry in the DataBase - if (!((_tcscmp (findData.cFileName, _T(".")) == 0) || (_tcscmp (findData.cFileName, _T("..")) == 0))) + if (!((_tcscmp(findData.cFileName, _T(".")) == 0) || (_tcscmp(findData.cFileName, _T("..")) == 0))) { string error; - if (!_ZoneBank.addElement (tStrToUtf8(findData.cFileName), error)) - theApp.errorMessage (error.c_str()); + if (!_ZoneBank.addElement(NLMISC::tStrToUtf8(findData.cFileName), error)) + theApp.errorMessage(error.c_str()); } - if (FindNextFile (hFind, &findData) == 0) + if (FindNextFile(hFind, &findData) == 0) break; } - SetCurrentDirectory (sDirBackup); + SetCurrentDirectory(sDirBackup); return true; } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp index 2b0a88527..e4cf1e670 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/dialog_properties.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -352,7 +355,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, string Name = widget.Parameter.Name; // Create a check box - nlverify (widget.CheckBox.Create (utf8ToTStr(Name), BS_3STATE|WS_VISIBLE|WS_TABSTOP|(enabled?0:WS_DISABLED), widgetPos, &m_PropertyCont, id)); + nlverify(widget.CheckBox.Create(nlUtf8ToTStr(Name), BS_3STATE | WS_VISIBLE | WS_TABSTOP | (enabled ? 0 : WS_DISABLED), widgetPos, &m_PropertyCont, id)); widget.CheckBox.SetFont (GetFont ()); } else if (widget.Parameter.Type == CPrimitiveClass::CParameter::ConstString) @@ -522,7 +525,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, for (vector::iterator it=PathList.begin(), itEnd=PathList.end(); it!=itEnd; ++it) { - widget.ListEditBox.StringSelectComboBox.InsertString( -1, utf8ToTStr(*it)); + widget.ListEditBox.StringSelectComboBox.InsertString( -1, nlUtf8ToTStr(*it)); } } @@ -549,7 +552,7 @@ void CDialogProperties::addWidget (const CPrimitiveClass::CParameter ¶meter, for (vector::iterator it=PathList.begin(), itEnd=PathList.end(); it!=itEnd; ++it) { - widget.ListEditBox.StringSelectComboBox.InsertString( -1, utf8ToTStr(*it)); + widget.ListEditBox.StringSelectComboBox.InsertString(-1, nlUtf8ToTStr(*it)); } } } @@ -915,11 +918,11 @@ bool CDialogProperties::CWidget::fromParameter (const IProperty *property, const updateBoolean (); break; case CPrimitiveClass::CParameter::ConstString: - if (Parameter.Editable || ComboBox.SelectString(-1, utf8ToTStr(propString->String)) == CB_ERR) + if (Parameter.Editable || ComboBox.SelectString(-1, nlUtf8ToTStr(propString->String)) == CB_ERR) { - ComboBox.SetWindowText(utf8ToTStr(propString->String)); - ComboBox.InsertString( -1, utf8ToTStr(propString->String)); - ComboBox.SelectString(-1, utf8ToTStr(propString->String)); + ComboBox.SetWindowText(nlUtf8ToTStr(propString->String)); + ComboBox.InsertString(-1, nlUtf8ToTStr(propString->String)); + ComboBox.SelectString(-1, nlUtf8ToTStr(propString->String)); } OriginalString = propString->String.c_str(); updateCombo (); @@ -953,7 +956,7 @@ bool CDialogProperties::CWidget::fromParameter (const IProperty *property, const updateBoolean (); break; case CPrimitiveClass::CParameter::ConstString: - ComboBox.SelectString(-1, utf8ToTStr(result)); + ComboBox.SelectString(-1, nlUtf8ToTStr(result)); OriginalString = result.c_str(); updateCombo (); break; @@ -1282,7 +1285,7 @@ void CDialogProperties::CWidget::updateCombo () DialogProperties->setDefaultValue (this, value); if (value != "") { - int index = ComboBox.FindString (-1, utf8ToTStr(value)); + int index = ComboBox.FindString(-1, nlUtf8ToTStr(value)); if (index != CB_ERR) ComboBox.SetCurSel (index); } @@ -1621,14 +1624,14 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) /* todo hulud remove CString oldValue; widget->EditBox.GetWindowText (oldValue);*/ - CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("default"), TRUE, utf8ToTStr(widget->Parameter.FileExtension), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, - utf8ToTStr(widget->Parameter.FileExtension+" (*."+widget->Parameter.FileExtension+")|*."+widget->Parameter.FileExtension+"|All Files (*.*)|*.*||"), getMainFrame ()); + CFileDialogEx dialog(BASE_REGISTRY_KEY, _T("default"), TRUE, nlUtf8ToTStr(widget->Parameter.FileExtension), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + nlUtf8ToTStr(widget->Parameter.FileExtension + " (*." + widget->Parameter.FileExtension + ")|*." + widget->Parameter.FileExtension + "|All Files (*.*)|*.*||"), getMainFrame()); TCHAR temp[MAX_PATH]; if (!widget->Parameter.Folder.empty()) { - _tcscpy_s(temp, MAX_PATH, utf8ToTStr(widget->Parameter.Folder)); + _tcscpy_s(temp, MAX_PATH, nlUtf8ToTStr(widget->Parameter.Folder)); dialog.m_ofn.lpstrInitialDir = temp; } @@ -1636,7 +1639,7 @@ BOOL CDialogProperties::OnCommand(WPARAM wParam, LPARAM lParam) { CString str; str = dialog.GetFileTitle(); - setWindowTextUTF8 (widget->EditBox, tStrToUtf8(str)); + setWindowTextUTF8 (widget->EditBox, NLMISC::tStrToUtf8(str)); /* todo hulud remove if ((const char*)oldValue != str) @@ -2305,7 +2308,7 @@ void CDialogProperties::rebuildDialog () m_ScrollBar.MoveWindow(&scrollRect, TRUE); // set the name of the dlg according to displayed class - SetWindowText( CString(_T("Properties for : ")) + utf8ToTStr(windowName) ); + SetWindowText(CString(_T("Properties for : ")) + nlUtf8ToTStr(windowName)); // // JC: added scrolling properties // ::CRect clientRect; @@ -2982,13 +2985,12 @@ void CDialogProperties::SelectFolder(CWidget *widget) LPITEMIDLIST pidlRoot = NULL; LPSHELLFOLDER desktop; - ULONG ulDummy; SHGetDesktopFolder (&desktop); if (widget->Parameter.Folder != "") { - desktop->ParseDisplayName (NULL, NULL, utf8ToTStr(widget->Parameter.Folder), &ulDummy, &pidlRoot, &ulDummy); + desktop->ParseDisplayName(NULL, NULL, (LPTSTR)nlUtf8ToTStr(widget->Parameter.Folder), NULL, &pidlRoot, NULL); } bi.pidlRoot = pidlRoot; @@ -3454,7 +3456,7 @@ void CMyComboBox::reloadData() SetRedraw(FALSE); InsertString(-1, _T("")); for (vector::iterator it=_data.begin(), itEnd=_data.end(); it!=itEnd; ++it) - InsertString(-1, utf8ToTStr(*it)); + InsertString(-1, nlUtf8ToTStr(*it)); loaded = true; SetRedraw(TRUE); if(n != CB_ERR) SelectString(-1, s); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp index 5f149f01e..30ff5bc81 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/display.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -318,7 +321,7 @@ void CDisplay::init (CMainFrame *pMF) } } - SetCurrentDirectory (utf8ToTStr(pMF->_ExeDir)); + SetCurrentDirectory (nlUtf8ToTStr(pMF->_ExeDir)); } // *************************************************************************** @@ -3554,7 +3557,7 @@ void CDisplay::DrawCollisionTexture(sint32 count, float x1, float y1) string dir = getDocument ()->getDataDir (); if (dir.empty()) dir = _MainFrame->_ExeDir; dir += "\\collisionmap\\"; - SetCurrentDirectory (utf8ToTStr(dir)); + SetCurrentDirectory(nlUtf8ToTStr(dir)); if(NLMISC::CFile::fileExists(Name+".tga") || NLMISC::CFile::fileExists(Name+".png")) { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp index 7f290b784..3767c78ef 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/export_dlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -162,9 +165,9 @@ int CALLBACK expBrowseCallbackProc (HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) // \return true if not canceled bool CExportDlg::callChoosePathDlg(CString &dest) const { - BROWSEINFO bi; - TCHAR str[MAX_PATH]; - ITEMIDLIST* pidl; + BROWSEINFO bi; + TCHAR str[MAX_PATH]; + LPITEMIDLIST pidl; TCHAR sTemp[1024]; bi.hwndOwner = this->m_hWnd; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp index 8e20608e6..5d21d2d73 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/external_editor.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -58,7 +61,7 @@ bool EditExternalText (const std::string &editor, std::string &text, const std:: } // Hide the file - SetFileAttributes (utf8ToTStr(tempFilename), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM); + SetFileAttributes(nlUtf8ToTStr(tempFilename), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); // Open the temp file with a text editor if (saved) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp index 47128cdb5..9a07fff77 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/file_dialog_ex.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -59,9 +62,9 @@ INT_PTR CFileDialogEx::DoModal () HKEY hKey; DWORD type = REG_SZ; DWORD size = 512 * sizeof(TCHAR); - if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(_RegistryPath), &hKey) == ERROR_SUCCESS) + if (RegCreateKey(HKEY_CURRENT_USER, nlUtf8ToTStr(_RegistryPath), &hKey) == ERROR_SUCCESS) { - if (RegQueryValueEx (hKey, utf8ToTStr(_FileType), 0, &type, (LPBYTE)path, &size) == ERROR_SUCCESS) + if (RegQueryValueEx(hKey, nlUtf8ToTStr(_FileType), 0, &type, (LPBYTE)path, &size) == ERROR_SUCCESS) m_ofn.lpstrInitialDir = path; } @@ -76,9 +79,9 @@ INT_PTR CFileDialogEx::DoModal () std::string newPath = NLMISC::CFile::getPath (tStrToUtf8(GetPathName())); TCHAR buffer[MAX_PATH]; - _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(newPath)); + _tcscpy_s(buffer, MAX_PATH, nlUtf8ToTStr(newPath)); - RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR)); + RegSetValueEx(hKey, nlUtf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR)); // Update the path list set oldPath; @@ -86,7 +89,7 @@ INT_PTR CFileDialogEx::DoModal () for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -112,7 +115,7 @@ void CFindPrimitiveDlg::OnFindNext() // || ( _Locator.Primitive->getPropertyByName ("selected", property) || ( getPrimitiveEditor(_Locator.Primitive)->getSelected())) // && property) ) - && _Locator.Primitive->getPropertyByName (tStrToUtf8(Property), property) + && _Locator.Primitive->getPropertyByName (NLMISC::tStrToUtf8(Property), property) && property) { // Kind of primitive ? @@ -120,7 +123,7 @@ void CFindPrimitiveDlg::OnFindNext() if (propString) { // Good value ? - if (propString->String.find(tStrToUtf8(Value))!=std::string::npos) + if (propString->String.find(NLMISC::tStrToUtf8(Value)) != std::string::npos) { found = true; } @@ -135,7 +138,7 @@ void CFindPrimitiveDlg::OnFindNext() uint i; for (i=0; iStringArray.size (); i++) { - if (propStringArray->StringArray[i].find(tStrToUtf8(Value))!=std::string::npos) + if (propStringArray->StringArray[i].find(NLMISC::tStrToUtf8(Value)) != std::string::npos) { found = true; } @@ -230,7 +233,7 @@ void CFindPrimitiveDlg::replace(bool all) // || ( _Locator.Primitive->getPropertyByName ("selected", property) || ( getPrimitiveEditor(_Locator.Primitive)->getSelected())) // && property) ) - && _Locator.Primitive->getPropertyByName (tStrToUtf8(Property), property) + && _Locator.Primitive->getPropertyByName(NLMISC::tStrToUtf8(Property), property) && property ) { // Kind of primitive ? @@ -238,14 +241,14 @@ void CFindPrimitiveDlg::replace(bool all) if (propString) { // Good value ? - if (propString->String.find(tStrToUtf8(Value))!=std::string::npos) + if (propString->String.find(NLMISC::tStrToUtf8(Value)) != std::string::npos) { if (!firstTime && !all) break; CString tmp(propString->String.c_str()); tmp.Replace(Value, ReplaceText); - doc->addModification (new CActionSetPrimitivePropertyString (_Locator, tStrToUtf8(Property), tStrToUtf8(tmp), false)); + doc->addModification(new CActionSetPrimitivePropertyString(_Locator, NLMISC::tStrToUtf8(Property), NLMISC::tStrToUtf8(tmp), false)); doc->addModification (new CActionSelect (_Locator)); firstTime=false; @@ -265,7 +268,7 @@ void CFindPrimitiveDlg::replace(bool all) for (i=0; iStringArray.size (); i++) { // todo. - if (propStringArray->StringArray[i].find(tStrToUtf8(Value))!=std::string::npos) + if (propStringArray->StringArray[i].find(NLMISC::tStrToUtf8(Value)) != std::string::npos) { if ( !firstTime && !all) @@ -281,7 +284,7 @@ void CFindPrimitiveDlg::replace(bool all) newStrings=propStringArray->StringArray; firstChange=false; } - newStrings[i] = tStrToUtf8(tmp); + newStrings[i] = NLMISC::tStrToUtf8(tmp); } firstTime=false; } @@ -290,7 +293,7 @@ void CFindPrimitiveDlg::replace(bool all) if (!firstChange) // have to make a change { - doc->addModification (new CActionSetPrimitivePropertyStringArray (_Locator, tStrToUtf8(Property), newStrings, false)); + doc->addModification(new CActionSetPrimitivePropertyStringArray(_Locator, NLMISC::tStrToUtf8(Property), newStrings, false)); doc->addModification (new CActionSelect (_Locator)); } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp index e4c5d0d8e..80585c5d8 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_dlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -75,7 +78,7 @@ BOOL CGenerateDlg::OnInitDialog() // TODO: Add extra initialization here for (uint32 i = 0; i < AllMaterials.size(); ++i) - ComboMaterial.InsertString(-1, utf8ToTStr(AllMaterials[i])); + ComboMaterial.InsertString(-1, nlUtf8ToTStr(AllMaterials[i])); ComboMaterial.SetCurSel (0); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_primitive.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_primitive.cpp index a7364a60e..c841a458c 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_primitive.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/generate_primitive.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -16,6 +19,8 @@ #include "stdafx.h" +#include + #include "editor_primitive.h" #include "generate_primitive.h" #include "world_editor.h" @@ -361,18 +366,15 @@ bool CGeneratePrimitive::generate (std::vector< std::vector > &dest } // Error ? - if (!_FileNotFound.empty ()) + if (!_FileNotFound.empty()) { // Continue ? - char message[2048]; - message[0] = 0; - for (uint i=0; i<_FileNotFound.size (); i++) + stringstream ssmessage; + for (uint i = 0; i < _FileNotFound.size(); i++) { - strcat (message, _FileNotFound[i].c_str ()); - strcat (message, "\n"); + ssmessage << _FileNotFound[i] << "\n"; } - - if (!theApp.yesNoMessage ("Can't load some files:\n%s\nContinue ?", message)) + if (!theApp.yesNoMessage("Can't load some files:\n%s\nContinue ?", ssmessage.str())) { return false; } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp index a24ef1c07..5601d3ed4 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -100,7 +103,7 @@ void CImageListEx::addResourceIcon (const char *filename) int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; // Load the icon - HICON handle = (HICON) LoadImage (NULL, utf8ToTStr(filename), IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); + HICON handle = (HICON) LoadImage (NULL, nlUtf8ToTStr(filename), IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); if (handle) { // Copy the icon diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp index c17d81198..ead8dd53d 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/main_frm.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -759,11 +762,11 @@ void CMainFrame::displayStatusBarInfo () string text; if (dispWnd->getActionHelp (text)) { - m_wndStatusBar.SetPaneText (0, utf8ToTStr(text)); + m_wndStatusBar.SetPaneText(0, nlUtf8ToTStr(text)); } else { - m_wndStatusBar.SetPaneText (0, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(0, nlUtf8ToTStr(sTmp)); } //for (uint32 i = sTmp.size(); i < 10; ++i) // sTmp += " "; @@ -771,12 +774,12 @@ void CMainFrame::displayStatusBarInfo () // Write zone reference name if (dispWnd->getActionText (text)) { - m_wndStatusBar.SetPaneText (1, utf8ToTStr(text)); + m_wndStatusBar.SetPaneText(1, nlUtf8ToTStr(text)); } else { sTmp = _ZoneBuilder->getZoneName (x, y); - m_wndStatusBar.SetPaneText (1, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(1, nlUtf8ToTStr(sTmp)); } // Write coordinates @@ -784,15 +787,15 @@ void CMainFrame::displayStatusBarInfo () sprintf(temp, "(%.3f , %.3f)", v.x, v.y); sTmp = temp; // sTmp = "( " + toString(v.x) + " , " + toString(v.y) + " )"; - m_wndStatusBar.SetPaneText (2, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(2, nlUtf8ToTStr(sTmp)); // Write rot sTmp = "Rot(" + toString(_ZoneBuilder->getRot(x, y)) + ")"; - m_wndStatusBar.SetPaneText (3, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(3, nlUtf8ToTStr(sTmp)); // Write flip sTmp = "Flip(" + toString(_ZoneBuilder->getFlip(x, y)) + ")"; - m_wndStatusBar.SetPaneText (4, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(4, nlUtf8ToTStr(sTmp)); // Write selection if (Selection.size ()) @@ -804,7 +807,7 @@ void CMainFrame::displayStatusBarInfo () } else sTmp = "No selected primitive"; - m_wndStatusBar.SetPaneText (5, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(5, nlUtf8ToTStr(sTmp)); // Write path of selected primitive if (Selection.size()) @@ -812,14 +815,14 @@ void CMainFrame::displayStatusBarInfo () else sTmp.clear(); - m_wndStatusBar.SetPaneText (6, utf8ToTStr(sTmp)); + m_wndStatusBar.SetPaneText(6, nlUtf8ToTStr(sTmp)); } // *************************************************************************** void CMainFrame::displayInfo (const std::string &info) { - m_wndStatusBar.SetPaneText (6, utf8ToTStr(info)); + m_wndStatusBar.SetPaneText(6, nlUtf8ToTStr(info)); } // *************************************************************************** @@ -858,7 +861,7 @@ void CMainFrame::uninit () } catch (const Exception& e) { - MessageBox (utf8ToTStr(e.what()), _T("Warning")); + MessageBox(nlUtf8ToTStr(e.what()), _T("Warning")); } } @@ -2710,7 +2713,7 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran // For each child, add a create method for (uint i=0; iDynamicChildren.size (); i++) { - pMenu->AppendMenu (MF_STRING, ID_EDIT_CREATE_BEGIN+i, utf8ToTStr("Add " + primClass->DynamicChildren[i].ClassName)); + pMenu->AppendMenu(MF_STRING, ID_EDIT_CREATE_BEGIN + i, nlUtf8ToTStr("Add " + primClass->DynamicChildren[i].ClassName)); } } @@ -2723,7 +2726,7 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran // For each child, add a create method for (uint i=0; iGeneratedChildren.size (); i++) { - pMenu->AppendMenu (MF_STRING, ID_EDIT_GENERATE_BEGIN+i, utf8ToTStr("Generate "+primClass->GeneratedChildren[i].ClassName)); + pMenu->AppendMenu(MF_STRING, ID_EDIT_GENERATE_BEGIN + i, nlUtf8ToTStr("Generate " + primClass->GeneratedChildren[i].ClassName)); } } @@ -2747,7 +2750,7 @@ void CMainFrame::createContextMenu (CWnd *parent, const CPoint &point, bool tran for (i=0; iAppendMenu (MF_STRING, ID_EDIT_OPEN_FILE_BEGIN+i, utf8ToTStr("Open " + NLMISC::CFile::getFilename (filenames[i]))); + pMenu->AppendMenu(MF_STRING, ID_EDIT_OPEN_FILE_BEGIN + i, nlUtf8ToTStr("Open " + NLMISC::CFile::getFilename(filenames[i]))); } } } @@ -3717,7 +3720,7 @@ void CMainFrame::OnProjectForceiduniqueness() // End modifications doc->endModification (); - AfxMessageBox(utf8ToTStr(NLMISC::toString("%u ids checked, %u non unique ID regenerated", ids.size()+nonUnique.size(), nonUnique.size())), MB_OK); + AfxMessageBox(nlUtf8ToTStr(NLMISC::toString("%u ids checked, %u non unique ID regenerated", ids.size() + nonUnique.size(), nonUnique.size())), MB_OK); } // *************************************************************************** @@ -4351,7 +4354,7 @@ void CMainFrame::OnMissionCompiler() } TCHAR path[MAX_PATH]; - _tcscpy(path, utf8ToTStr(var->asString())); + _tcscpy(path, nlUtf8ToTStr(var->asString())); SHELLEXECUTEINFO ExecuteInfo; memset(&ExecuteInfo, 0, sizeof(ExecuteInfo)); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp index a071a4836..bcce5fc2a 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/my_list_box.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -69,7 +72,7 @@ BOOL CMyListBox::OnCommand(WPARAM wParam, LPARAM lParam) std::string str; getWindowTextUTF8 (StringSelectComboBox, str); DeleteString(_EditingItem); - InsertString(_EditingItem, utf8ToTStr(str)); + InsertString(_EditingItem, nlUtf8ToTStr(str)); SetCurSel (_SelectAfter); _EditingItem = LB_ERR; notifyParent (); diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp index bfa978ee4..d05fb6fc9 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/name_dlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -88,7 +91,7 @@ BOOL CNameDlg::OnInitDialog() // print the data directory CWnd* pWnd = GetDlgItem(IDC_NAME_DIR); - pWnd->SetWindowText(CString(_T("Data directory: ")) + utf8ToTStr(m_dataDir)); + pWnd->SetWindowText(CString(_T("Data directory: ")) + nlUtf8ToTStr(m_dataDir)); // tab stops to simulate multi-columns edit boxes int tab_stop1[1] = {160}; @@ -156,18 +159,18 @@ void CNameDlg::updateSearchList() { // no filter m_listToName.insert(std::make_pair(j, i)); - m_searchList.InsertString(j++, utf8ToTStr(s)); + m_searchList.InsertString(j++, nlUtf8ToTStr(s)); } else { - std::string filter(tStrToUtf8(m_nameFilter.LockBuffer())); + std::string filter(NLMISC::tStrToUtf8(m_nameFilter.LockBuffer())); m_nameFilter.UnlockBuffer(); // filter if (NLMISC::toLower(ig).find(NLMISC::toLower(filter)) != std::string::npos) { m_listToName.insert(std::make_pair(j, i)); - m_searchList.InsertString(j++, utf8ToTStr(s)); + m_searchList.InsertString(j++, nlUtf8ToTStr(s)); } } } @@ -214,7 +217,7 @@ void CNameDlg::updateSelectList() m_listToId.insert(std::make_pair(i, row)); } - m_idList.InsertString(i++, utf8ToTStr(s)); + m_idList.InsertString(i++, nlUtf8ToTStr(s)); } } @@ -251,8 +254,8 @@ void CNameDlg::OnBtnAssign() // get strings ucstring id; - std::string gn = tStrToUtf8(m_assignGn); - std::string ig = tStrToUtf8(m_assignIg); + std::string gn = NLMISC::tStrToUtf8(m_assignGn); + std::string ig = NLMISC::tStrToUtf8(m_assignIg); for (uint i=0 ; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -114,7 +117,7 @@ BOOL CPrimitiveConfigurationDlg::OnInitDialog() uint i; for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -75,9 +78,9 @@ void CProjectSettings::OnBrowse() { UpdateData (); - BROWSEINFO bi; - TCHAR str[MAX_PATH]; - ITEMIDLIST* pidl; + BROWSEINFO bi; + TCHAR str[MAX_PATH]; + LPITEMIDLIST pidl; TCHAR sTemp[1024]; bi.hwndOwner = this->m_hWnd; @@ -133,11 +136,11 @@ BOOL CProjectSettings::OnInitDialog() for (uint i=0; igetContext ())); + Context.SelectString(-1, nlUtf8ToTStr(doc->getContext())); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h index 2a294d748..d90a7e8c0 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/resource.h @@ -1,21 +1,5 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - //{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. +// Microsoft Visual C++ generated include file. // Used by world_editor.rc // #define IDC_BROWSE 3 @@ -341,7 +325,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 178 +#define _APS_NEXT_RESOURCE_VALUE 179 #define _APS_NEXT_COMMAND_VALUE 33485 #define _APS_NEXT_CONTROL_VALUE 1022 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/stdafx.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/stdafx.h index d8fe8ec31..9f1a88c97 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/stdafx.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/stdafx.h @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2016-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -25,8 +29,13 @@ #pragma once #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp index 7a5c25553..bc5b04522 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_logic.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -1231,7 +1234,7 @@ BOOL CCreateDialog::OnInitDialog () for (uint32 i = 0; i < TypesForInit->size(); ++i) { - ComboType.InsertString (-1, utf8ToTStr(TypesForInit->operator[](i).Name)); + ComboType.InsertString(-1, nlUtf8ToTStr(TypesForInit->operator[](i).Name)); } if (TypesForInit->size()>0) @@ -1264,10 +1267,10 @@ void CCreateDialog::OnOK() UpdateData (); // If the "region_" do not exist add it - if (_tcsnccmp(utf8ToTStr(RegionPost), Name, strlen(RegionPost.c_str())) != 0) + if (_tcsnccmp(nlUtf8ToTStr(RegionPost), Name, strlen(RegionPost.c_str())) != 0) { TCHAR sTmp[128]; - _tcscpy (sTmp, utf8ToTStr(RegionPost)); + _tcscpy(sTmp, nlUtf8ToTStr(RegionPost)); _tcscat (sTmp, Name); _tcscpy (Name, sTmp); UpdateData (false); @@ -1303,11 +1306,11 @@ void CCreateDialog::OnSelChange () if (PropType == tStrToUtf8(sTmp)) { - _tcscpy (Name, utf8ToTStr(PropName)); + _tcscpy(Name, nlUtf8ToTStr(PropName)); } else { - _tcscpy(Name, utf8ToTStr(RegionPost)); + _tcscpy(Name, nlUtf8ToTStr(RegionPost)); _tcscat (Name, (LPCTSTR)sTmp); _tcscat (Name, _T("-")); } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp index 231e57d28..ee4da6308 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/tools_zone.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -105,7 +108,7 @@ void CToolsZoneList::reset() void CToolsZoneList::addItem (const string &itemName) { _ItemNames.push_back (itemName); - InsertString (-1, utf8ToTStr(itemName)); + InsertString(-1, nlUtf8ToTStr(itemName)); } // --------------------------------------------------------------------------- @@ -118,13 +121,12 @@ const string &CToolsZoneList::getItem (uint32 nIndex) void CToolsZoneList::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct) { ASSERT(lpDrawItemStruct->CtlType == ODT_LISTBOX); - LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData; - if (lpszText == NULL) - return; CDC dc; if (lpDrawItemStruct->itemID >= _BitmapList.size()) return; + if (lpDrawItemStruct->itemID >= _ItemNames.size()) + return; dc.Attach (lpDrawItemStruct->hDC); @@ -168,7 +170,8 @@ void CToolsZoneList::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct) } // Draw the text. - dc.DrawText (lpszText, _tcslen(lpszText), &rectLeft, DT_CENTER|DT_SINGLELINE|DT_VCENTER); + NLMISC::tstring itemName = NLMISC::utf8ToTStr(_ItemNames[lpDrawItemStruct->itemID]); + dc.DrawText(itemName.c_str(), itemName.size(), &rectLeft, DT_CENTER|DT_SINGLELINE|DT_VCENTER); // Reset the background color and the text color back to their original values. dc.SetTextColor (crOldTextColor); @@ -259,15 +262,15 @@ CToolsZoneList *CToolsZone::getListCtrl() // --------------------------------------------------------------------------- void CToolsZone::addToAllCatTypeCB (const string &Name) { - CComboBox* pCB; - pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE1); - pCB->AddString (utf8ToTStr(Name)); - pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE2); - pCB->AddString (utf8ToTStr(Name)); - pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE3); - pCB->AddString (utf8ToTStr(Name)); - pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE4); - pCB->AddString (utf8ToTStr(Name)); + CComboBox *pCB; + pCB = (CComboBox *)GetDlgItem(IDC_CATTYPE1); + pCB->AddString(nlUtf8ToTStr(Name)); + pCB = (CComboBox *)GetDlgItem(IDC_CATTYPE2); + pCB->AddString(nlUtf8ToTStr(Name)); + pCB = (CComboBox *)GetDlgItem(IDC_CATTYPE3); + pCB->AddString(nlUtf8ToTStr(Name)); + pCB = (CComboBox *)GetDlgItem(IDC_CATTYPE4); + pCB->AddString(nlUtf8ToTStr(Name)); } // --------------------------------------------------------------------------- @@ -285,26 +288,26 @@ void CToolsZone::init (CMainFrame *pMF) // Select right category types CComboBox* pCB; pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE1); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType1)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType1)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE2); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType2)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType2)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE3); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType3)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType3)); pCB = (CComboBox*)GetDlgItem (IDC_CATTYPE4); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType4)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterType4)); updateComboPairAndFilter (IDC_CATTYPE1, IDC_CATVALUE1, &_MainFrame->_ZoneBuilder->_FilterType1); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE1); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue1)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue1)); updateComboPairAndFilter (IDC_CATTYPE2, IDC_CATVALUE2, &_MainFrame->_ZoneBuilder->_FilterType2); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE2); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue2)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue2)); updateComboPairAndFilter (IDC_CATTYPE3, IDC_CATVALUE3, &_MainFrame->_ZoneBuilder->_FilterType3); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE3); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue3)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue3)); updateComboPairAndFilter (IDC_CATTYPE4, IDC_CATVALUE4, &_MainFrame->_ZoneBuilder->_FilterType4); pCB = (CComboBox*)GetDlgItem (IDC_CATVALUE4); - pCB->SelectString (-1, utf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue4)); + pCB->SelectString(-1, nlUtf8ToTStr(_MainFrame->_ZoneBuilder->_FilterValue4)); // Select right operators CButton *pButAnd, *pButOr; @@ -436,7 +439,7 @@ void CToolsZone::updateComboPairAndFilter (int CatTypeId, int CatValueId, string CComboBox *pCBType, *pCBValue; pCBType = (CComboBox*)GetDlgItem (CatTypeId); pCBType->GetLBText (pCBType->GetCurSel(), sTmp); - *pFilterType = tStrToUtf8(sTmp); + *pFilterType = NLMISC::tStrToUtf8(sTmp); pCBValue = (CComboBox*)GetDlgItem (CatValueId); pCBValue->ResetContent (); @@ -446,7 +449,7 @@ void CToolsZone::updateComboPairAndFilter (int CatTypeId, int CatValueId, string vector allCategoryValues; _MainFrame->_ZoneBuilder->getZoneBank().getCategoryValues (*pFilterType, allCategoryValues); for(i = 0; i < allCategoryValues.size(); ++i) - pCBValue->AddString (utf8ToTStr(allCategoryValues[i])); + pCBValue->AddString(nlUtf8ToTStr(allCategoryValues[i])); pCBValue->SetCurSel (0); } @@ -488,7 +491,7 @@ void CToolsZone::OnSelectCatValue1() TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE1); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue1 = tStrToUtf8(sTmp); + _MainFrame->_ZoneBuilder->_FilterValue1 = NLMISC::tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } @@ -498,7 +501,7 @@ void CToolsZone::OnSelectCatValue2() TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE2); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue2 = tStrToUtf8(sTmp); + _MainFrame->_ZoneBuilder->_FilterValue2 = NLMISC::tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } @@ -508,7 +511,7 @@ void CToolsZone::OnSelectCatValue3() TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE3); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue3 = tStrToUtf8(sTmp); + _MainFrame->_ZoneBuilder->_FilterValue3 = NLMISC::tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } @@ -518,7 +521,7 @@ void CToolsZone::OnSelectCatValue4() TCHAR sTmp[256]; CComboBox *pCBValue = (CComboBox*)GetDlgItem (IDC_CATVALUE4); pCBValue->GetLBText (pCBValue->GetCurSel(), sTmp); - _MainFrame->_ZoneBuilder->_FilterValue4 = tStrToUtf8(sTmp); + _MainFrame->_ZoneBuilder->_FilterValue4 = NLMISC::tStrToUtf8(sTmp); _MainFrame->_ZoneBuilder->updateToolsZone (); } diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp index ed39bda8e..8b2f5d033 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_manager_dlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -77,7 +80,7 @@ void CTypeManagerDlg::OnAddtype() if (typeDlg.DoModal() == IDOK) { SType typeTmp; - typeTmp.Name = tStrToUtf8(typeDlg.EditName); + typeTmp.Name = NLMISC::tStrToUtf8(typeDlg.EditName); typeTmp.Color = typeDlg.ButtonColorValue; // Check if the name of the new type is the same as an existing one bool bFound = false; @@ -91,7 +94,7 @@ void CTypeManagerDlg::OnAddtype() if (!bFound) { LocalTypes.push_back (typeTmp); - ListType.InsertString(-1, utf8ToTStr(typeTmp.Name)); + ListType.InsertString(-1, nlUtf8ToTStr(typeTmp.Name)); } } } @@ -111,11 +114,11 @@ void CTypeManagerDlg::OnEdittype() if (typeDlg.DoModal() == IDOK) { SType typeTmp; - typeTmp.Name = tStrToUtf8(typeDlg.EditName); + typeTmp.Name = NLMISC::tStrToUtf8(typeDlg.EditName); typeTmp.Color = typeDlg.ButtonColorValue; LocalTypes[cursel] = typeTmp; ListType.DeleteString (ListType.GetCurSel()); - ListType.InsertString (cursel, utf8ToTStr(typeTmp.Name)); + ListType.InsertString(cursel, nlUtf8ToTStr(typeTmp.Name)); } } @@ -138,7 +141,7 @@ BOOL CTypeManagerDlg::OnInitDialog() // TODO: Add extra initialization here for (uint32 i = 0; i < LocalTypes.size(); ++i) { - ListType.InsertString(-1, utf8ToTStr(LocalTypes[i].Name)); + ListType.InsertString(-1, nlUtf8ToTStr(LocalTypes[i].Name)); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp index 347fc72ad..8bb9afbae 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/type_sel_dlg.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -60,7 +63,7 @@ void CTypeSelDlg::OnOK() CString sTmp; TypeList.GetText(TypeList.GetCurSel(), sTmp); - _TypeSelected = tStrToUtf8(sTmp); + _TypeSelected = NLMISC::tStrToUtf8(sTmp); CDialog::OnOK(); } @@ -72,7 +75,7 @@ BOOL CTypeSelDlg::OnInitDialog() // TODO: Add extra initialization here for (uint32 i = 0; i < _TypesInit->size(); ++i) { - TypeList.InsertString(-1, utf8ToTStr(_TypesInit->operator[](i).Name)); + TypeList.InsertString(-1, nlUtf8ToTStr(_TypesInit->operator[](i).Name)); } return TRUE; // return TRUE unless you set the focus to a control diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/version.rc2 b/code/ryzom/tools/leveldesign/world_editor/world_editor/version.rc2 new file mode 100644 index 000000000..a11050b22 --- /dev/null +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/version.rc2 @@ -0,0 +1,64 @@ + +#ifndef NL_VERSION_RC2 +#define NL_VERSION_RC2 + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL +#pragma code_page(65001) + +#include +#include "config.h" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom World Editor" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "world_editor" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 73 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About World Editor" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT NL_VERSION,IDC_TITLE_VERSION,40,10,96,8,SS_NOPREFIX + LTEXT COPYRIGHT,IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,8,50,14,WS_GROUP + LTEXT "Allocated Video Mem :",IDC_STATIC,15,43,73,16 + LTEXT "Static",IDC_STATIC_VIDEO_MEM,97,43,87,16 +END + +#endif /* #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) */ +#endif /* #ifndef NL_VERSION_RC2 */ diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp index 1b3f96d04..6ad30ccb7 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -170,7 +173,7 @@ BOOL CWorldEditorApp::InitInstance() } catch (const Exception& e) { - ::MessageBox (NULL, utf8ToTStr(e.what()), _T("Warning"), MB_OK|MB_ICONEXCLAMATION); + ::MessageBox(NULL, nlUtf8ToTStr(e.what()), _T("Warning"), MB_OK | MB_ICONEXCLAMATION); // Can't found the module put some default values Config.CellSize = 160.0f; @@ -292,7 +295,7 @@ BOOL CWorldEditorApp::InitInstance() { IPluginCallback* test=Plugins[k]; string retest=test->getName(); - menu->InsertMenu( k, MF_BYPOSITION | MF_POPUP, ID_WINDOWS_PLUGINS+1 + k, utf8ToTStr(retest) ); + menu->InsertMenu(k, MF_BYPOSITION | MF_POPUP, ID_WINDOWS_PLUGINS + 1 + k, nlUtf8ToTStr(retest)); menu->CheckMenuItem(ID_WINDOWS_PLUGINS+1 +k, MF_CHECKED); } @@ -444,7 +447,7 @@ bool CWorldEditorApp::yesNoMessage (const char *format, ... ) strcpy(buffer, "Unknown error"); } - return MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, utf8ToTStr(buffer), _T("NeL World Editor"), MB_YESNO|MB_ICONQUESTION) == IDYES; + return MessageBox(m_pMainWnd ? m_pMainWnd->m_hWnd : NULL, nlUtf8ToTStr(buffer), _T("NeL World Editor"), MB_YESNO | MB_ICONQUESTION) == IDYES; } void CWorldEditorApp::errorMessage (const char *format, ... ) @@ -463,7 +466,7 @@ void CWorldEditorApp::errorMessage (const char *format, ... ) strcpy(buffer, "Unknown error"); } - MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, utf8ToTStr(buffer), _T("NeL World Editor"), MB_OK|MB_ICONEXCLAMATION); + MessageBox(m_pMainWnd ? m_pMainWnd->m_hWnd : NULL, nlUtf8ToTStr(buffer), _T("NeL World Editor"), MB_OK | MB_ICONEXCLAMATION); } void CWorldEditorApp::infoMessage (const char *format, ... ) @@ -482,7 +485,7 @@ void CWorldEditorApp::infoMessage (const char *format, ... ) strcpy(buffer, "Unknown error"); } - MessageBox (m_pMainWnd?m_pMainWnd->m_hWnd:NULL, utf8ToTStr(buffer), _T("NeL World Editor"), MB_OK|MB_ICONINFORMATION); + MessageBox(m_pMainWnd ? m_pMainWnd->m_hWnd : NULL, nlUtf8ToTStr(buffer), _T("NeL World Editor"), MB_OK | MB_ICONINFORMATION); } void CWorldEditorApp::syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...) @@ -813,7 +816,7 @@ void setEditTextMultiLine (CListBox &listBox, const std::vector &ve listBox.ResetContent(); uint i; for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -830,7 +833,7 @@ void CWorldEditorDoc::updateModifiedState () if ( (title.size ()>=2) && (title[title.size()-1] == '*') && (title[title.size()-2] == ' ') ) { title.resize (title.size () - 2); - SetTitle (utf8ToTStr(title)); + SetTitle(nlUtf8ToTStr(title)); } } } @@ -1532,8 +1535,8 @@ const NLLIGO::IPrimitive *CWorldEditorDoc::createPrimitive (const CDatabaseLocat if (primClass->Type == CPrimitiveClass::Bitmap) { // Create a dialog file - CFileDialogEx dialog (BASE_REGISTRY_KEY, _T("image"), TRUE, utf8ToTStr(primClass->FileExtension), NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, - utf8ToTStr(toString("%s (*.%s)|*.%s|All Files (*.*)|*.*||", primClass->FileType.c_str(), primClass->FileExtension.c_str(), primClass->FileExtension.c_str())), getMainFrame ()); + CFileDialogEx dialog(BASE_REGISTRY_KEY, _T("image"), TRUE, nlUtf8ToTStr(primClass->FileExtension), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + nlUtf8ToTStr(toString("%s (*.%s)|*.%s|All Files (*.*)|*.*||", primClass->FileType.c_str(), primClass->FileExtension.c_str(), primClass->FileExtension.c_str())), getMainFrame()); if (dialog.DoModal() == IDOK) { // Save filename diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h index 2e9f07fe2..a8ceb45c1 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/world_editor_doc.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/StdAfx.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/StdAfx.h index 58043f752..11c3a0aee 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/StdAfx.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/StdAfx.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -27,8 +30,13 @@ #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/StdAfx.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/StdAfx.h index 9beea91c6..ecac82483 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/StdAfx.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/StdAfx.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -27,8 +30,13 @@ #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp index d42b14eb8..864d79681 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/graph_plugin.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -172,7 +175,7 @@ void CGraphPlugin::refreshPrimitives() { string msg("Can't write script file '"); msg += tmpPath+"/lang.dot'"; - AfxMessageBox(utf8ToTStr(msg)); + AfxMessageBox(nlUtf8ToTStr(msg)); } else { @@ -207,11 +210,11 @@ void CGraphPlugin::refreshPrimitives() err = toString("%s : %s", primName.c_str(), e.Why.c_str()); } - AfxMessageBox(utf8ToTStr(err)); + AfxMessageBox(nlUtf8ToTStr(err)); } catch (const exception &e) //catch a possible exception from getRootFileName { - AfxMessageBox(utf8ToTStr(e.what())); + AfxMessageBox(nlUtf8ToTStr(e.what())); } } else @@ -254,7 +257,7 @@ void CGraphPlugin::refreshMachine() { string msg("Can't write script file '"); msg += tmpPath+"/lang.dot'"; - AfxMessageBox(utf8ToTStr(msg)); + AfxMessageBox(nlUtf8ToTStr(msg)); } else { @@ -298,7 +301,7 @@ void CGraphPlugin::refreshMachine() { string msg("Can't write script file '"); msg += tmpPath+"/lang.dot'"; - AfxMessageBox(utf8ToTStr(msg)); + AfxMessageBox(nlUtf8ToTStr(msg)); } else { @@ -940,7 +943,7 @@ void CGraphPlugin::doSelection(const string& primPath) } catch(const exception &e) { - GraphDlg->MessageBox(utf8ToTStr(e.what())); + GraphDlg->MessageBox(nlUtf8ToTStr(e.what())); } } } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/CMakeLists.txt index 56a7c1597..da490aa57 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/CMakeLists.txt @@ -14,9 +14,9 @@ NL_ADD_LIB_SUFFIX(world_editor_primitive_plugin) ADD_DEFINITIONS(${MFC_DEFINITIONS} -DWIN32_DLL_EXPORTS) -IF(WITH_PCH) - ADD_NATIVE_PRECOMPILED_HEADER(world_editor_primitive_plugin ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) -ENDIF() +#IF(WITH_PCH) +# ADD_NATIVE_PRECOMPILED_HEADER(world_editor_primitive_plugin ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h ${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.cpp) +#ENDIF() INSTALL(TARGETS world_editor_primitive_plugin LIBRARY DESTINATION ${RYZOM_LIB_PREFIX} RUNTIME DESTINATION ${RYZOM_BIN_PREFIX} ARCHIVE DESTINATION ${RYZOM_LIB_PREFIX} COMPONENT tools3d) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h index 8b452cd80..7712c7f07 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2012-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -18,8 +21,13 @@ #define PRIMITIVE_PLUGIN_H #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp index 12c3d9b88..b4dc971d6 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/DialogFlags.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -301,7 +304,7 @@ void CDialogFlags::setCurrentEntityDisplayMode(TEntityDisplayMode edm) void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos, const std::string ®Id) { HKEY hKey; - if (RegOpenKeyEx(HKEY_CURRENT_USER, utf8ToTStr(tStrToUtf8(REGKEY_ENTITY_DISPLAY_INFO) + regId), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + if (RegOpenKeyEx(HKEY_CURRENT_USER, nlUtf8ToTStr(tStrToUtf8(REGKEY_ENTITY_DISPLAY_INFO) + regId), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { DWORD index = 0; for(;;) @@ -338,7 +341,7 @@ void CDialogFlags::loadEntityDisplayInfoToRegistry(TEntityDisplayInfoVect &infos void CDialogFlags::saveEntityDisplayInfoToRegistry(const TEntityDisplayInfoVect &infos, const std::string ®Id) { HKEY hKey; - if (RegCreateKeyEx(HKEY_CURRENT_USER, utf8ToTStr(tStrToUtf8(REGKEY_ENTITY_DISPLAY_INFO) + regId), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) + if (RegCreateKeyEx(HKEY_CURRENT_USER, nlUtf8ToTStr(tStrToUtf8(REGKEY_ENTITY_DISPLAY_INFO) + regId), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) { for(uint k = 0; k < infos.size(); ++k) { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/StdAfx.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/StdAfx.h index c62c05e5b..66cc7ebe3 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/StdAfx.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/StdAfx.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -29,8 +32,13 @@ #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp index 09756ddbf..cf9cf36cf 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/memory_combo_box.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -95,14 +98,14 @@ bool CMemoryComboBox::getMemory (int slot, std::string &ret) { // Open the key HKEY hKey; - if (RegOpenKey (HKEY_CURRENT_USER, utf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) + if (RegOpenKey(HKEY_CURRENT_USER, nlUtf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) { // Get the value char strSrc[512]; smprintf (strSrc, 512, "%d", slot); TCHAR str[512]; long size = 512*sizeof(TCHAR); - if (RegQueryValue (hKey, utf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) + if (RegQueryValue(hKey, nlUtf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { ret = tStrToUtf8(str); @@ -124,7 +127,7 @@ void CMemoryComboBox::scrollDown (int start, int end) { // Open the key HKEY hKey; - if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) + if (RegCreateKey (HKEY_CURRENT_USER, nlUtf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) { // Scroll down the list for (int i=end-1; i>start; i--) @@ -134,12 +137,12 @@ void CMemoryComboBox::scrollDown (int start, int end) smprintf (strSrc, 512, "%d", i-1); TCHAR str[512]; long size = 512 * sizeof(TCHAR); - if (RegQueryValue (hKey, utf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) + if (RegQueryValue(hKey, nlUtf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { // Set the value char strDst[512]; smprintf (strDst, 512, "%d", i); - RegSetValue (hKey, utf8ToTStr(strDst), REG_SZ, str, size); + RegSetValue(hKey, nlUtf8ToTStr(strDst), REG_SZ, str, size); } } @@ -154,10 +157,10 @@ void CMemoryComboBox::writeStringInRegistry (const std::string &str) { // Open the key HKEY hKey; - if (RegCreateKey (HKEY_CURRENT_USER, utf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) + if (RegCreateKey(HKEY_CURRENT_USER, nlUtf8ToTStr(RegisterAdress), &hKey) == ERROR_SUCCESS) { // Set the value - RegSetValue (hKey, _T("0"), REG_SZ, utf8ToTStr(str), str.size ()); + RegSetValue(hKey, _T("0"), REG_SZ, nlUtf8ToTStr(str), str.size()); // Close RegCloseKey (hKey); @@ -428,7 +431,7 @@ void CMemoryComboBox::pushString (const std::string &str) if (i == (int)(itemCount+Commands.size()+ StaticStrings.size())) { // Insert the sting - _ComboBox.InsertString (Commands.size()+ StaticStrings.size(), utf8ToTStr(str)); + _ComboBox.InsertString(Commands.size() + StaticStrings.size(), nlUtf8ToTStr(str)); } } } @@ -449,7 +452,7 @@ void CMemoryComboBox::refreshStrings () int count = Commands.size(); for (i=0; i // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -1189,7 +1192,7 @@ void CPlugin::updateConnectionState() // Change the text _DialogFlag->ConnectCtrl.SetWindowText (getStringRsc(IDS_DISCONNECT)); _DialogFlag->State = (LPCTSTR) (getStringRsc(IDS_CONNECTED_TO) + _SHost.c_str()); - _DialogFlag->Sent = CString(utf8ToTStr(toString (_Client->getBytesSent ()))) + getStringRsc(IDS_BYTE_SENT); + _DialogFlag->Sent = CString(nlUtf8ToTStr(toString(_Client->getBytesSent()))) + getStringRsc(IDS_BYTE_SENT); //_DialogFlag->Received = (toString ((uint32)_Client->getBytesReceived ()) + " bytes received").c_str(); _DialogFlag->Received = (toString("%.1f", bandwidth/1024.0) + " kB/s").c_str(); _DialogFlag->DownloadValue = (toString("%.1f kB/s", _DialogFlag->Download/1024.0)).c_str(); @@ -1198,7 +1201,7 @@ void CPlugin::updateConnectionState() break; case WaitingServerParams: _DialogFlag->ConnectCtrl.SetWindowText (getStringRsc(IDS_CANCEL_CONNECT)); - _DialogFlag->State = getStringRsc(IDS_WAITING_SERVER_PARAMS) + utf8ToTStr(_SHost); + _DialogFlag->State = getStringRsc(IDS_WAITING_SERVER_PARAMS) + nlUtf8ToTStr(_SHost); break; case WaitingLoginConfirmation: { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp index 55cbbd25c..f931ab9f1 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/DialogFlags.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -118,7 +121,7 @@ void CDialogFlags::init(CSoundPlugin *plugin) for (uint i =0; i(GetDlgItem(BG_FLAG_ID[i]))->SetCheck(flags.Flags[i] ? 1 : 0); - GetDlgItem(BG_FLAG_ID[i])->SetWindowText(utf8ToTStr(_Mixer->getBackgroundFlagName(i))); + GetDlgItem(BG_FLAG_ID[i])->SetWindowText(nlUtf8ToTStr(_Mixer->getBackgroundFlagName(i))); } @@ -229,7 +232,7 @@ void CDialogFlags::OnTimer(UINT_PTR nIDEvent) _stprintf(temp, _T("%6.2f"), SampleBanks[i].second / (1024.0f*1024.0f)); TCHAR bankName[1024]; - _tcscpy_s(bankName, 1024, utf8ToTStr(SampleBanks[i].first)); + _tcscpy_s(bankName, 1024, nlUtf8ToTStr(SampleBanks[i].first)); if (i < c) { diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/StdAfx.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/StdAfx.h index 33e78a8b1..4b709cc42 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/StdAfx.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/StdAfx.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -29,8 +32,13 @@ #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN #define NOMINMAX -#define _WIN32_WINNT 0x0501 +#ifdef _WIN64 +#define _WIN32_WINNT 0x0600 +#else +#define _WIN32_WINNT 0x0500 +#endif #include // MFC core and standard components #include // MFC extensions diff --git a/code/ryzom/tools/patch_gen/CMakeLists.txt b/code/ryzom/tools/patch_gen/CMakeLists.txt index 6cde9810b..477e13c26 100644 --- a/code/ryzom/tools/patch_gen/CMakeLists.txt +++ b/code/ryzom/tools/patch_gen/CMakeLists.txt @@ -1,15 +1,15 @@ -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ryzom/client/src/seven_zip) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/nel/3rdparty/seven_zip) -SET(MAIN_SRC patch_gen_common.cpp patch_gen_main.cpp patch_gen_main.h) -SET(SERVICE_SRC patch_gen_common.cpp patch_gen_service.cpp patch_gen_service.h) +SET(MAIN_SRC patch_gen_common.cpp patch_gen_main.cpp patch_gen_main.h patch_gen.rc) +SET(SERVICE_SRC patch_gen_common.cpp patch_gen_service.cpp patch_gen_service.h patch_gen_service.rc) -ADD_EXECUTABLE(patch_gen ${MAIN_SRC}) -TARGET_LINK_LIBRARIES(patch_gen ryzom_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges) +ADD_EXECUTABLE(patch_gen ${MAIN_SRC} ${RECS}) +TARGET_LINK_LIBRARIES(patch_gen nel_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges) NL_DEFAULT_PROPS(patch_gen "Ryzom, Tools: Patch Generator") NL_ADD_RUNTIME_FLAGS(patch_gen) -ADD_EXECUTABLE(patch_gen_service WIN32 ${SERVICE_SRC}) -TARGET_LINK_LIBRARIES(patch_gen_service ryzom_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges) +ADD_EXECUTABLE(patch_gen_service WIN32 ${SERVICE_SRC} ${RECS}) +TARGET_LINK_LIBRARIES(patch_gen_service nel_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges) NL_DEFAULT_PROPS(patch_gen_service "Ryzom, Tools: Patch Generator Service") NL_ADD_RUNTIME_FLAGS(patch_gen_service) diff --git a/code/ryzom/tools/patch_gen/blue_pill.ico b/code/ryzom/tools/patch_gen/blue_pill.ico new file mode 100644 index 000000000..269907ec3 Binary files /dev/null and b/code/ryzom/tools/patch_gen/blue_pill.ico differ diff --git a/code/ryzom/tools/patch_gen/patch_gen.rc b/code/ryzom/tools/patch_gen/patch_gen.rc new file mode 100644 index 000000000..c950b655b --- /dev/null +++ b/code/ryzom/tools/patch_gen/patch_gen.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "blue_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Patch Gen" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "patch_gen" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/code/ryzom/tools/patch_gen/patch_gen_common.cpp b/code/ryzom/tools/patch_gen/patch_gen_common.cpp index 8ba0d4c5e..a9502517d 100644 --- a/code/ryzom/tools/patch_gen/patch_gen_common.cpp +++ b/code/ryzom/tools/patch_gen/patch_gen_common.cpp @@ -1,6 +1,11 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2011-2013 Matt RAYKOWSKI (sfb) +// Copyright (C) 2014 Matthew LAGOE (Botanic) +// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -26,8 +31,8 @@ #include "nel/misc/file.h" #include "nel/misc/command.h" #include "nel/misc/sstring.h" +#include "nel/misc/seven_zip.h" #include "game_share/singleton_registry.h" -#include "seven_zip.h" using namespace std; using namespace NLMISC; @@ -454,7 +459,8 @@ void CPackageDescription::buildDefaultFileList() std::vector fileList; NLMISC::CPath::getPathContent(_BnpDirectory,false,false,true,fileList); for (uint32 i=0;i +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "red_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Patch Gen Service" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "patch_gen_service" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/code/ryzom/tools/patch_gen/red_pill.ico b/code/ryzom/tools/patch_gen/red_pill.ico new file mode 100644 index 000000000..c5f250583 Binary files /dev/null and b/code/ryzom/tools/patch_gen/red_pill.ico differ diff --git a/code/ryzom/tools/pd_parser/parser.cpp b/code/ryzom/tools/pd_parser/parser.cpp index d4ae04508..80492e8b6 100644 --- a/code/ryzom/tools/pd_parser/parser.cpp +++ b/code/ryzom/tools/pd_parser/parser.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2015 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/server/ai_build_wmap/CMakeLists.txt b/code/ryzom/tools/server/ai_build_wmap/CMakeLists.txt index f6417611f..edafe195f 100644 --- a/code/ryzom/tools/server/ai_build_wmap/CMakeLists.txt +++ b/code/ryzom/tools/server/ai_build_wmap/CMakeLists.txt @@ -1,4 +1,6 @@ -FILE(GLOB SRC *.cpp *.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.cpp) +FILE(GLOB SRC *.cpp *.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.cpp *.rc) + +SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(ai_build_wmap ${SRC}) diff --git a/code/ryzom/tools/server/ai_build_wmap/blue_pill.ico b/code/ryzom/tools/server/ai_build_wmap/blue_pill.ico new file mode 100644 index 000000000..269907ec3 Binary files /dev/null and b/code/ryzom/tools/server/ai_build_wmap/blue_pill.ico differ diff --git a/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp b/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp index ed8f775c3..e77e7f777 100644 --- a/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp +++ b/code/ryzom/tools/server/ai_build_wmap/build_proximity_maps.cpp @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/server/ai_build_wmap/main.cpp b/code/ryzom/tools/server/ai_build_wmap/main.cpp index 9fa9f4408..80183c9c4 100644 --- a/code/ryzom/tools/server/ai_build_wmap/main.cpp +++ b/code/ryzom/tools/server/ai_build_wmap/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/server/ai_build_wmap/main.rc b/code/ryzom/tools/server/ai_build_wmap/main.rc new file mode 100644 index 000000000..1ef42e0dc --- /dev/null +++ b/code/ryzom/tools/server/ai_build_wmap/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "blue_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom AI Build WMap" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "ai_build_wmap" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/code/ryzom/tools/server/build_world_packed_col/CMakeLists.txt b/code/ryzom/tools/server/build_world_packed_col/CMakeLists.txt index 672500092..e1d57f821 100644 --- a/code/ryzom/tools/server/build_world_packed_col/CMakeLists.txt +++ b/code/ryzom/tools/server/build_world_packed_col/CMakeLists.txt @@ -1,4 +1,6 @@ -FILE(GLOB SRC *.cpp *.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.cpp) +FILE(GLOB SRC *.cpp *.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.h ${RZ_SERVER_SRC_DIR}/ai_data_service/pacs_scan.cpp *.rc) + +SOURCE_GROUP("" FILES ${SRC}) ADD_EXECUTABLE(build_world_packed_col ${SRC}) diff --git a/code/ryzom/tools/server/build_world_packed_col/blue_pill.ico b/code/ryzom/tools/server/build_world_packed_col/blue_pill.ico new file mode 100644 index 000000000..269907ec3 Binary files /dev/null and b/code/ryzom/tools/server/build_world_packed_col/blue_pill.ico differ diff --git a/code/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp b/code/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp index b9ab53f98..f274f29cc 100644 --- a/code/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp +++ b/code/ryzom/tools/server/build_world_packed_col/build_world_packed_col.cpp @@ -1,6 +1,10 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2010-2014 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -114,6 +118,7 @@ int main(int argc, char* argv[]) CPath::remapExtension("dds", "png", true); // R2::CScenarioEntryPoints &sep = R2::CScenarioEntryPoints::getInstance(); + sep.setFiles(builderConfig.CompleteIslandsFile, builderConfig.EntryPointsFile); try { sep.loadCompleteIslands(); diff --git a/code/ryzom/tools/server/build_world_packed_col/builder_config.cpp b/code/ryzom/tools/server/build_world_packed_col/builder_config.cpp index 32778a8c2..11e8a0524 100644 --- a/code/ryzom/tools/server/build_world_packed_col/builder_config.cpp +++ b/code/ryzom/tools/server/build_world_packed_col/builder_config.cpp @@ -28,6 +28,8 @@ CBuilderConfig::CBuilderConfig() CachePath = "island_packed_zones_cache"; CWMapCachePath = "island_cwmap_cache"; OutputPath = "islands_col_meshes"; + CompleteIslandsFile = "r2_islands.xml"; + EntryPointsFile = "r2_entry_points.txt"; CamSpeed = 100; Fly = false; HeightMapsAsTga = false; @@ -76,6 +78,18 @@ void CBuilderConfig::build(NLMISC::CConfigFile &cf) } } // + CConfigFile::CVar *completeIslandsFileVar = cf.getVarPtr("CompleteIslandsFile"); + if (completeIslandsFileVar) + { + CompleteIslandsFile = completeIslandsFileVar->asString(); + } + // + CConfigFile::CVar *entryPointsFileVar = cf.getVarPtr("EntryPointsFile"); + if (entryPointsFileVar) + { + EntryPointsFile = entryPointsFileVar->asString(); + } + // CConfigFile::CVar *camSpeedVar = cf.getVarPtr("CamSpeed"); if (camSpeedVar) { diff --git a/code/ryzom/tools/server/build_world_packed_col/builder_config.h b/code/ryzom/tools/server/build_world_packed_col/builder_config.h index 86fa380b0..9f64bfb0f 100644 --- a/code/ryzom/tools/server/build_world_packed_col/builder_config.h +++ b/code/ryzom/tools/server/build_world_packed_col/builder_config.h @@ -31,6 +31,8 @@ public: std::vector SearchPaths; std::vector CWMapList; std::string CWMapCachePath; + std::string CompleteIslandsFile; + std::string EntryPointsFile; float CamSpeed; bool Fly; bool HeightMapsAsTga; diff --git a/code/ryzom/tools/server/build_world_packed_col/main.rc b/code/ryzom/tools/server/build_world_packed_col/main.rc new file mode 100644 index 000000000..38046dc1f --- /dev/null +++ b/code/ryzom/tools/server/build_world_packed_col/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "blue_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "Ryzom Build World Packed Collisions" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "build_world_packed_col" NL_FILEEXT ".exe" + VALUE "ProductName", "Ryzom Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp b/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp index 779e4102d..37e801012 100644 --- a/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp +++ b/code/ryzom/tools/server/build_world_packed_col/packed_world_builder.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/.classpath b/code/ryzom/tools/server/ryzom_ams/android_app/.classpath deleted file mode 100644 index c3c8602bb..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/.project b/code/ryzom/tools/server/ryzom_ams/android_app/.project deleted file mode 100644 index ba01a3a61..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - MyAndroidApp - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/.settings/org.eclipse.jdt.core.prefs b/code/ryzom/tools/server/ryzom_ams/android_app/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 2a856569f..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Tue Feb 21 13:19:14 SGT 2012 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/AndroidManifest.xml b/code/ryzom/tools/server/ryzom_ams/android_app/AndroidManifest.xml deleted file mode 100644 index 70e45aa6c..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/AndroidManifest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/BuildConfig.java b/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/BuildConfig.java deleted file mode 100644 index b068a863d..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/BuildConfig.java +++ /dev/null @@ -1,6 +0,0 @@ -/** Automatically generated file. DO NOT MODIFY */ -package com.mkyong.android; - -public final class BuildConfig { - public final static boolean DEBUG = true; -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/R.java b/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/R.java deleted file mode 100644 index a451800e7..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/gen/com/mkyong/android/R.java +++ /dev/null @@ -1,25 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package com.mkyong.android; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int ic_launcher=0x7f020000; - } - public static final class id { - public static final int webView1=0x7f050000; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/info.txt b/code/ryzom/tools/server/ryzom_ams/android_app/info.txt deleted file mode 100644 index ef44bdf75..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/info.txt +++ /dev/null @@ -1 +0,0 @@ -Info: Android Application Made by Matthew Lagoe for browsing the AMS on your android device! diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/proguard.cfg b/code/ryzom/tools/server/ryzom_ams/android_app/proguard.cfg deleted file mode 100644 index b1cdf17b5..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/proguard.cfg +++ /dev/null @@ -1,40 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/project.properties b/code/ryzom/tools/server/ryzom_ams/android_app/project.properties deleted file mode 100644 index 73fc66102..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/project.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-18 diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-hdpi/ic_launcher.png b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 8074c4c57..000000000 Binary files a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-ldpi/ic_launcher.png b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 1095584ec..000000000 Binary files a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable/ic_launcher.png b/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable/ic_launcher.png deleted file mode 100644 index a07c69fa5..000000000 Binary files a/code/ryzom/tools/server/ryzom_ams/android_app/res/drawable/ic_launcher.png and /dev/null differ diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/layout/main.xml b/code/ryzom/tools/server/ryzom_ams/android_app/res/layout/main.xml deleted file mode 100644 index 41627df16..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/res/layout/main.xml +++ /dev/null @@ -1,7 +0,0 @@ - - \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/res/values/strings.xml b/code/ryzom/tools/server/ryzom_ams/android_app/res/values/strings.xml deleted file mode 100644 index 09b33f582..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Ryzom Core AMS - \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/android_app/src/com/mkyong/android/MainActivity.java b/code/ryzom/tools/server/ryzom_ams/android_app/src/com/mkyong/android/MainActivity.java deleted file mode 100644 index 260856c52..000000000 --- a/code/ryzom/tools/server/ryzom_ams/android_app/src/com/mkyong/android/MainActivity.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mkyong.android; - -import android.app.Activity; -import android.os.Bundle; -import android.webkit.WebView; -import android.webkit.WebViewClient; - -public class MainActivity extends Activity { - - private WebView webView; - - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - webView = (WebView) findViewById(R.id.webView1); - webView.setWebViewClient(new WebViewClient()); - webView.getSettings().setJavaScriptEnabled(true); - webView.loadUrl("http://shard.ryzomcore.org/ams/index.php"); - - } -} diff --git a/code/ryzom/tools/server/ryzom_ams/credits.txt b/code/ryzom/tools/server/ryzom_ams/credits.txt deleted file mode 100644 index d2878080a..000000000 --- a/code/ryzom/tools/server/ryzom_ams/credits.txt +++ /dev/null @@ -1,7 +0,0 @@ -################################################################### -CREDITS REGARDING THE AMS -################################################################## -- Muhammad Usman (Charisma Layout http://usman.it/themes/charisma/) -- prdatur (Icon Set http://opengameart.org/users/prdatur) -- Tobi (original Drupal Module) -- Botanic (Mentoring & original drupal module) diff --git a/code/ryzom/tools/server/ryzom_ams/doc.txt b/code/ryzom/tools/server/ryzom_ams/doc.txt deleted file mode 100644 index 6aa2b5bc9..000000000 --- a/code/ryzom/tools/server/ryzom_ams/doc.txt +++ /dev/null @@ -1 +0,0 @@ -The following variables are required and must be set to a variable (not constant) and called before including ams_lib/libinclude.php \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.info b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.info deleted file mode 100644 index 0f33e5cf6..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.info +++ /dev/null @@ -1,10 +0,0 @@ -; $Id$ -name = Ryzom Account Manager -description = Ryzom Login Service Integration - inserts and updates users and manages accounts. -core = 7.x -package = Ryzom Plugins -configure = admin/settings/ryzommanage - -; Information added by drupal.org packaging script on 2012-04-24 -version = "7.x-.01" -core = "7.x" \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.install b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.install deleted file mode 100644 index 4575f2dbd..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.install +++ /dev/null @@ -1,31 +0,0 @@ - 'Ryzom Manager', - 'machine_name' => 'ryzommanage', - 'description' => 'Ryzom Login Service integration - inserts and updates users and manages accounts.', - 'module' => 'ryzommanage', - ); - $vocab = (object) $vocab; - db_query("CREATE TABLE ryzommanage_querycache ( - `SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `type` VARCHAR( 64 ) NOT NULL , - `query` VARCHAR( 512 ) NOT NULL - );"); - -} - -function ryzommanage_uninstall() { - db_query("DROP TABLE ryzommanage_querycache;"); -} - -function _ryzommanage_vocab_fields() { - -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module deleted file mode 100644 index f09b06a37..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module +++ /dev/null @@ -1,931 +0,0 @@ -. -*/ - -require_once("/ams_lib/libinclude.php"); - -//output template -function loadTemplate($template,$vars) -{ - extract($vars); - include($template); -} -/** - * - * Function ryzommanage_admin - * - * @takes Nothing - * @return array $form - * - * Info: Creates the box's etc that go in the ryzom admin menu - * - */ -function ryzommanage_admin() -{ - $form = array(); - //admin menu items - $form['ryzommanage_serverurl'] = array( - '#type' => 'textfield', - '#title' => t('Server url'), - '#default_value' => variable_get('ryzommanage_serverurl', 'localhost'), - '#description' => t("The url of the ryzom server to integrate with."), - '#required' => TRUE - ); - $form['ryzommanage_mysqlport'] = array( - '#type' => 'textfield', - '#title' => t('Port for MySQL'), - '#size' => 5, - '#maxlength' => 5, - '#default_value' => variable_get('ryzommanage_mysqlport', '3306'), - '#description' => t("The MySQL port of the ryzom server to integrate with."), - '#required' => TRUE, - '#element_validate' => array( - '_check_port_value' - ) - ); - $form['ryzommanage_dbname'] = array( - '#type' => 'textfield', - '#title' => t('Database Name'), - '#default_value' => variable_get('ryzommanage_dbname', 'nel'), - '#description' => t("The MySQL database name to connect to."), - '#required' => TRUE - ); - $form['ryzommanage_username'] = array( - '#type' => 'textfield', - '#title' => t('MySQL Username'), - '#default_value' => variable_get('ryzommanage_username', 'root'), - '#description' => t("The MySQL username to connect with."), - '#required' => TRUE - ); - $form['ryzommanage_password'] = array( - '#type' => 'password_confirm', - '#title' => t('MySQL Password'), - '#description' => t("Confirm the MySQL password.") - ); - return system_settings_form($form); -} -//validate registration webpage -function ryzommanage_form_alter(&$form, &$form_state, $form_id) -{ - if($form_id == "user_register_form") - { - $form['#validate'][] = '_webpage_registration'; - } elseif($form_id == "user_profile_form") { - $form['#validate'][] = '_webpage_profile'; - } -} - -function _webpage_registration(&$form_state) -{ - - $user = checkUser($form_state['account']['name']['#value']); - $email = validEmail($form_state['account']['mail']['#value']); - - if ($user != "success") { - form_set_error('name', t($user)); - } - if ($email != "success") { - form_set_error('mail', t('Not a valid email address, please check it and try again.')); - } - -} - -function _webpage_profile(&$form_state) -{ - $email = validEmail($form_state['account']['mail']['#value']); - - if ($email != "success") { - form_set_error('mail', t('Not a valid email address, please check it and try again.')); - } - if ((checkPassword($form_state['account']['pass']['#value']['pass1']) == "success" ) and ( $form_state['account']['pass']['#value']['pass1'] == - $form_state['account']['pass']['#value']['pass2'] )) { - } -} - -/** - * - * Function ryzommanage_menu - * - * @takes Nothing - * @return array $items - * - * Info: Creates the menu item in the admin interface - * - */ -function ryzommanage_menu() -{ - $items = array(); - //page for client registration - $items['register'] = array( - 'title' => 'register', - 'page callback' => '_collect_register', - 'page arguments' => array(1, 2), - 'access callback' => 'user_access', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - //main menu item - $items['admin/config/ryzommanage'] = array( - 'title' => 'Ryzom Server Integration', - 'description' => 'Ryzom integration information.', - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array( - 'administer site configuration' - ), - 'file' => 'system.admin.inc', - 'file path' => drupal_get_path('module', 'system') - ); - // First submenu item - $items['admin/config/ryzommanage/serversettings'] = array( - 'title' => 'Ryzom Server Settings', - 'description' => 'This is the first child item in the section', - 'page callback' => 'drupal_get_form', - 'page arguments' => array( - 'ryzommanage_admin' - ), - 'access arguments' => array( - 'administer site configuration' - ) - ); - // Second submenu item - $items['admin/config/ryzommanage/nameregister'] = array( - 'title' => 'Name Registration Settings', - 'description' => 'Configure default behavior of name registration module.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array( - 'name_registration_admin_settings' - ), - 'access arguments' => array( - 'administer site configuration' - ) - ); - return $items; -} -function name_registration_admin_settings() { - $form = array(); - $form['ryzommanage_game-name'] = array( - '#type' => 'textfield', - '#title' => t('Game Name'), - '#default_value' => variable_get('ryzommanage_game-name', ''), - '#description' => t("Name of game used on registration pages."), - '#required' => TRUE - ); - //this is not the TOS url used in the create account page, you change that in the config of the client with the ConditionsTermsURL value - $form['ryzommanage_TOS'] = array( - '#type' => 'textfield', - '#title' => t('Terms of Service URL'), - '#default_value' => variable_get('ryzommanage_TOS', ''), - '#description' => t("The url of the TOS for your server."), - '#required' => TRUE - ); - $form['ryzommanage_register-welcome'] = array( - '#type' => 'textarea', - '#title' => t('Registration Welcome Message'), - '#default_value' => variable_get('ryzommanage_register-welcome', ''), - '#description' => t("Registration welcome message on first page of create account."), - '#required' => TRUE - ); - - return system_settings_form($form); -} -/** - * - * Function ryzommanage_menu - * - * @takes Int $element, &$form_state - * @return Nothing - * - * Info: Used by ryzommanage_mysqlport to validate ryzommanage_admin will run form_error if port is not between 1 and 65535. - * - */ -function _check_port_value($element, &$form_state) -{ - if ((!is_numeric(parse_size($element['#value']))) or ((parse_size($element['#value']) > 65535) or (parse_size($element['#value']) < 1))) { - form_error($element, t($element['#value'] . ' is not a valid value for the MySQL port, it must be a valid value. You must choose a number between 1 and 65535.')); - } -} -/** - * - * Function ryzommanage_block_info - * - * @takes Nothing - * @return array $blocks - * - * Info: Info for block that shows the user menu - * - */ -function ryzommanage_block_info() -{ - $blocks['ryzommanage_usersblock'] = array( - // info: The name of the block. - 'info' => t('Ryzom Manage User Block'), - 'status' => TRUE, - 'region' => '-1', // Not usually provided. - 'visibility' => BLOCK_VISIBILITY_LISTED // Not usually provided. - ); - return $blocks; -} -/** - * - * Function ryzommanage_block_view - * - * @takes Nothing - * @return array $block - * - * Info: View for block - * - */ -function ryzommanage_block_view($delta = '') -{ - $block = array(); - //The $delta parameter tells us which block is being requested. - switch ($delta) { - case 'ryzommanage_usersblock': - $block['subject'] = t("uppercase this please"); - $block['content'] = top_bar(); - break; - } - return $block; -} -/** - * - * Function _collect_register - * - * @takes - * @return Nothing - * - * Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to / - * - */ -function _collect_register($nids, $collection) -{ - syncdata(); - //if not using ryzom core client show registration page - if (check_if_game_client()) { - return_client_httpdata(); - } else { - //redirect to registration page - header("Location: /user/register"); - } -} -/** - * - * Function check_if_game_client - * - * @takes Nothing - * @return Boolean - * - * Info: Returns True if connecting client is ryzom core - * - */ -function check_if_game_client() -{ - //if HTTP_USER_AGENT is not set then its ryzom core - if (!isset($_SERVER['HTTP_USER_AGENT'])) { - return true; - } else { - return false; - } -} -/** - * - * Function return_client_httpdata - * - * @takes - * @return - * - * Info: Returns ryzom core formatted html for use in registration via client - * - */ -function return_client_httpdata() -{ - //check if values exist - if (isset($_POST["Username"]) and isset($_POST["Password"]) and isset($_POST["Email"]) ) - { - //check values - $user = checkUser($_POST["Username"]); - $pass = checkPassword($_POST["Password"]); - $cpass = confirmPassword(); - $email = checkEmail($_POST["Email"]); - } else { - $user = ""; - $pass = ""; - $cpass = ""; - $email = ""; - } - //if all are good then create user - if (($user == "success") and ($pass == "success") and ($cpass == "success") and ($email == "success") and (isset($_POST["TaC"]))) { - $edit = array( - 'name' => $_POST["Username"], - 'pass' => $_POST["Password"], - 'mail' => $_POST["Email"], - 'init' => $_POST["Email"], - 'unhashpass' => $_POST["Password"], - 'status' => 1, - 'access' => REQUEST_TIME - ); - user_save(NULL, $edit); - header('Location: email_sent.php'); - exit; - } else { - $pageElements = array( - 'GAME_NAME' => variable_get('ryzommanage_game-name', ''), - 'WELCOME_MESSAGE' => variable_get('ryzommanage_register-welcome', ''), - 'USERNAME' => $user, - 'PASSWORD' => $pass, - 'CPASSWORD' => $cpass, - 'EMAIL' => $email - ); - if ($user != "success") { - $pageElements['USERNAME_ERROR'] = 'TRUE'; - } else { - $pageElements['USERNAME_ERROR'] = 'FALSE'; - } - - if ($pass != "success") { - $pageElements['PASSWORD_ERROR'] = 'TRUE'; - } else { - $pageElements['PASSWORD_ERROR'] = 'FALSE'; - } - if ($cpass != "success") { - $pageElements['CPASSWORD_ERROR'] = 'TRUE'; - } else { - $pageElements['CPASSWORD_ERROR'] = 'FALSE'; - } - if ($email != "success") { - $pageElements['EMAIL_ERROR'] = 'TRUE'; - } else { - $pageElements['EMAIL_ERROR'] = 'FALSE'; - } - if (isset($_POST["TaC"])) { - $pageElements['TAC_ERROR'] = 'FALSE'; - } else { - $pageElements['TAC_ERROR'] = 'TRUE'; - } - loadTemplate('templates/ingame_register.phtml',$pageElements); - } -} -/** - * - * Function checkUser - * - * @takes $username - * @return string - * - * Info: Returns a string based on if the username is valid, if valid then "success" is returned - * - */ -function checkUser($username) -{ - if (isset($username)) { - if (strlen($username) > 12) { - return "Username must be no more than 12 characters."; - } elseif (strlen($username) < 5) { - return "Username must be 5 or more characters."; - } elseif (!preg_match('/^[a-z0-9\.]*$/', $username)) { - return "Username can only contain numbers and letters."; - } elseif (db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array( - ':name' => $username - ))->fetchField()) { - return "Username " . $username . " is in use."; - } else { - return "success"; - } - } else { - return "success"; - } - return "fail"; -} -/** - * - * Function checkPassword - * - * @takes $pass - * @return string - * - * Info: Returns a string based on if the password is valid, if valid then "success" is returned - * - */ -function checkPassword($pass) -{ - if (isset($pass)) { - if (strlen($pass) > 20) { - return "Password must be no more than 20 characters."; - } elseif (strlen($pass) < 5) { - return "Password must be more than 5 characters."; - } else { - return "success"; - } - } - return "fail"; -} -/** - * - * Function confirmPassword - * - * @takes $pass - * @return string - * - * Info: Verify's $_POST["Password"] is the same as $_POST["ConfirmPass"] - * - */ -function confirmPassword() -{ - if (($_POST["Password"]) != ($_POST["ConfirmPass"])) { - return "Passwords do not match."; - } else { - return "success"; - } - return "fail"; -} -/** - * - * Function checkEmail - * - * @takes $email - * @return - * - * - * - */ -function checkEmail($email) -{ - if (isset($email)) { - if (!validEmail($email)) { - return "Email address is not valid."; - } elseif (db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail", array( - ':mail' => $email - ))->fetchField()) { - return "Email is in use."; - } else { - return "success"; - } - } else { - return "success"; - } - return "fail"; -} -function validEmail($email) -{ - $isValid = true; - $atIndex = strrpos($email, "@"); - if (is_bool($atIndex) && !$atIndex) { - $isValid = false; - } else { - $domain = substr($email, $atIndex + 1); - $local = substr($email, 0, $atIndex); - $localLen = strlen($local); - $domainLen = strlen($domain); - if ($localLen < 1 || $localLen > 64) { - // local part length exceeded - $isValid = false; - } else if ($domainLen < 1 || $domainLen > 255) { - // domain part length exceeded - $isValid = false; - } else if ($local[0] == '.' || $local[$localLen - 1] == '.') { - // local part starts or ends with '.' - $isValid = false; - } else if (preg_match('/\\.\\./', $local)) { - // local part has two consecutive dots - $isValid = false; - } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { - // character not valid in domain part - $isValid = false; - } else if (preg_match('/\\.\\./', $domain)) { - // domain part has two consecutive dots - $isValid = false; - } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) { - // character not valid in local part unless - // local part is quoted - if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) { - $isValid = false; - } - } - if ($isValid && !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) { - // domain not found in DNS - $isValid = false; - } - } - return $isValid; -} -function generateSALT($length = 2) -{ - // start with a blank salt - $salt = ""; - // define possible characters - any character in this string can be - // picked for use in the salt, so if you want to put vowels back in - // or add special characters such as exclamation marks, this is where - // you should do it - $possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ"; - // we refer to the length of $possible a few times, so let's grab it now - $maxlength = strlen($possible); - // check for length overflow and truncate if necessary - if ($length > $maxlength) { - $length = $maxlength; - } - // set up a counter for how many characters are in the salt so far - $i = 0; - // add random characters to $salt until $length is reached - while ($i < $length) { - // pick a random character from the possible ones - $char = substr($possible, mt_rand(0, $maxlength - 1), 1); - // have we already used this character in $salt? - if (!strstr($salt, $char)) { - // no, so it's OK to add it onto the end of whatever we've already got... - $salt .= $char; - // ... and increase the counter by one - $i++; - } - } - // done! - return $salt; -} -function createUser($values) -{ - - $login = $values[0]; - $pass = $values[1]; - $email = $values[2]; - - $salt = generateSALT(); - $hashpass = crypt($pass, $salt); - - $params = array( - $login, - $hashpass, - $email - ); - - try { - $hostname = variable_get('ryzommanage_serverurl', 'localhost'); - $port = variable_get('ryzommanage_mysqlport', '3306'); - $dbname = variable_get('ryzommanage_dbname', 'nel'); - $username = variable_get('ryzommanage_username', 'root'); - $password = variable_get('ryzommanage_password', ''); - $dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createUser", - "query" => json_encode(array( - $login, - $pass, - $email - )) - ))->execute(); - return true; - } - - try { - $statement = $dbh->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)"); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createUser", - "query" => json_encode(array( - $login, - $pass, - $email - )) - ))->execute(); - return true; - } - - try { - $statement->execute($params); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createUser", - "query" => json_encode(array( - $login, - $pass, - $email - )) - ))->execute(); - return true; - } - - createPermissions(array($login)); -} - -function createPermissions($values) { - - try { - $hostname = variable_get('ryzommanage_serverurl', 'localhost'); - $port = variable_get('ryzommanage_mysqlport', '3306'); - $dbname = variable_get('ryzommanage_dbname', 'nel'); - $username = variable_get('ryzommanage_username', 'root'); - $password = variable_get('ryzommanage_password', ''); - $dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createPermissions", - "query" => json_encode(array( - $values[0] - )) - ))->execute(); - return true; - } - - try { - $sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';"); - $sth->execute(); - $result = $sth->fetchAll(); - /*foreach ($result as $UId) { - $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'r2', 'OPEN');"); - $statement->execute($values); - $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'ryzom_open', 'OPEN');"); - $statement->execute($values); - }*///FIXME: GARBAGE - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createPermissions", - "query" => json_encode(array( - $values[0] - )) - ))->execute(); - return true; - } - - return true; -} - -function login_form($login_form) -{ - $login_form['#action'] = url(current_path(), array( - 'query' => drupal_get_destination(), - 'external' => FALSE - )); - $login_form['#id'] = 'user-login-form'; - $login_form['#validate'] = user_login_default_validators(); - $login_form['#submit'][] = 'user_login_submit'; - $login_form['name'] = array( - '#type' => 'textfield', - '#title' => t('Username'), - '#maxlength' => 12, - '#size' => 15, - '#required' => TRUE - ); - $login_form['pass'] = array( - '#type' => 'password', - '#title' => t('Password'), - '#maxlength' => 20, - '#size' => 15, - '#required' => TRUE - ); - $items = array(); - if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { - $items[] = l(t('Create new account'), 'user/register', array( - 'attributes' => array( - 'title' => t('Create a new user account.') - ) - )); - } - $items[] = l(t('Request new password'), 'user/password', array( - 'attributes' => array( - 'title' => t('Request new password via e-mail.') - ) - )); - $login_form['links'] = array( - '#markup' => theme('item_list', array( - 'items' => $items - )) - ); - $login_form['remember_me'] = array( - '#type' => 'checkbox', - '#title' => t('Remember Me'), - '#default_value' => 0 - ); - $login_form['actions'] = array( - '#type' => 'actions' - ); - $login_form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Log in') - ); - return $login_form; -} - -function top_bar() -{ - global $user; - $userId = $user->uid; - if (user_is_logged_in()) { - // Logged in user - return "
Notepad | Mail | Wiki | Profile | Craft Recipe-Book | Occupations | News/Events | Account | Logout
"; - } else { - return drupal_get_form('login_form'); - // Not logged in - } -} - -function ryzommanage_user_presave(&$edit, $account, $category) -{ - if (isset($edit['unhashpass'])) { - $pass = $edit['unhashpass']; - } elseif (isset($_POST['pass']['pass1'])) { - $pass = $_POST['pass']['pass1']; - } - - if (!isset($edit['name'])) { - $name = $user->name; - } else { - $name = $edit['name']; - } - - if ($account->is_new == 1 ) { - createUser(array($edit['name'], $pass, $edit['mail'])); - } else { - user_edit( array($edit['name'], $pass)); - } -} - -function ryzommanage_form_user_register_form_alter(&$form, &$form_state, $form_id) { - // Modification for the form with the given form ID goes here. For example, if - // FORM_ID is "user_register_form" this code would run only on the user - // registration form. - - // Change the data for the username and email fields - $form['account']['name']['#maxlength'] = '12'; - $form['account']['name']['#description'] = '5-12 lower-case characters and numbers. The login (username) you create here will be your login name.
The name of your game characters will be chosen later on.
'; - $form['account']['mail']['#description'] = 'Please verify that the e-mail address you enter here is valid and will remain valid in the future.
It will be used to manage your Tempest in the Aether account.
'; - // Add a checkbox to registration form about agreeing to terms of use. - $form['terms_of_use'] = array( - '#type' => 'checkbox', - '#title' => t("I agree with the terms and conditions."), - '#required' => TRUE, - ); -} - -function ryzommanage_form_user_profile_form_alter(&$form, &$form_state, $form_id) { - // Modification for the form with the given form ID goes here. For example, if - // FORM_ID is "user_register_form" this code would run only on the user - // registration form. - - // Change the data for the password field - $form['account']['pass']['#description'] = 'Password must be 5-20 characters.
'; -} - -function user_edit($values) { - - $username = $values[0]; - $newpassword = $values[1]; - - $salt = generateSALT(); - $pass = crypt($newpassword, $salt); - - try { - $hostname = variable_get('ryzommanage_serverurl', 'localhost'); - $port = variable_get('ryzommanage_mysqlport', '3306'); - $dbname = variable_get('ryzommanage_dbname', 'nel'); - $ryusername = variable_get('ryzommanage_username', 'root'); - $password = variable_get('ryzommanage_password', ''); - $dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $ryusername, $password); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "user_edit", - "query" => json_encode(array( - $username, - $newpassword - )) - ))->execute(); - return true; - } - - $sql = "UPDATE `nel`.`user` SET `Password` = ? WHERE `user`.`Login` = ?"; - - try { - $q = $dbh->prepare($sql); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "user_edit", - "query" => json_encode(array( - $username, - $newpassword - )) - ))->execute(); - return true; - } - - try { - $q->execute(array( $pass, $username)); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "user_edit", - "query" => json_encode(array( - $username, - $newpassword - )) - ))->execute(); - return true; - } - - return true; -} - -/** - * - * Function syncdata - * - * @takes Nothing - * @return array $values - * - * Info: Runs functions to finish syncing data when shard is offline - * - */ -function syncdata () { - - try { - $hostname = variable_get('ryzommanage_serverurl', 'localhost'); - $port = variable_get('ryzommanage_mysqlport', '3306'); - $dbname = variable_get('ryzommanage_dbname', 'nel'); - $ryusername = variable_get('ryzommanage_username', 'root'); - $password = variable_get('ryzommanage_password', ''); - $dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $ryusername, $password); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - return true; - } - - $query = db_select('ryzommanage_querycache', 'q') - ->fields('q', array('SID', 'type', 'query')); - - $result = $query->execute(); - - foreach ($result as $record) { - watchdog('ryzommanage_usersync', $record->query, NULL, WATCHDOG_ERROR); - - switch($record->type) { - case 'createPermissions': - case 'user_edit': - case 'createUser': - watchdog('ryzommanage_usersync', $record->type, NULL, WATCHDOG_INFO); - $SID = $record->SID; - $num_deleted = db_delete('ryzommanage_querycache') - ->condition('SID', $SID) - ->execute(); - $func = $record->type; - $func(json_decode($record->query)); - } - - } - -} -/** - * - * Function ryzommanage_cron - * - * @takes - * @return - * - * Info: Runs the syncdata function with the drupal cron - * - */ -function ryzommanage_cron() { - - syncdata(); - -} diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/templates/ingame_register.phtml b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/templates/ingame_register.phtml deleted file mode 100644 index 1f0fc0859..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/templates/ingame_register.phtml +++ /dev/null @@ -1,116 +0,0 @@ -
- RYZOM CORE INGAME REGISTRATION -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You must accept the Terms of Service';} - else { - echo ' -
id="caption-Username">Desired Username: - - width="42%">
id="caption-Password">Desired Password: - - width="42%">
id="caption-ConfirmPass">Confirm Password: - width="42%">
id="caption-Email">Email Address (to which a confirmation email will be sent): - account.', this);" /> - width="42%">
- colspan="2">YES, I agree to the terms of - service';}; ?> -
- -
- -
- - -
- -
- 5-12 lower-case characters and numbers. The login (username) you create here will be - your login name. The name of your game characters will be chosen later on. -
- -
- 5-20 characters. -
- -
- Retype your Password -
- -
- Please verify that the e-mail address you enter here is valid and will remain valid - in the future. It will be used to manage your account. -
- -
\ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/ingame_templates/settings.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/ingame_templates/settings.tpl deleted file mode 100644 index 50d47d680..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/ingame_templates/settings.tpl +++ /dev/null @@ -1,161 +0,0 @@ -{block name=content} - - - - - - - - -
- - - - -
- - - - - {if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1} - {if $userPermission eq 1} - - - {else if $userPermission eq 2 } - - - {else if $userPermission eq 3 } - - - {/if} - {/if} - -
Browse UserSend TicketMake ModeratorMake AdminDemote to UserMake AdminDemote to UserDemote to Moderator
-
-
- - - - - - - - - - - - -

Change Settings of {$target_username}

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

Change Password

- -
- - {if !isset($changesOther) or $changesOther eq "FALSE"} - - - -

- - {/if} - - - -
- Current Password: - - - {if isset($MATCH_ERROR) and $MATCH_ERROR eq "TRUE"}The password is incorrect{/if} -
- New Password: - - - {if isset($NEWPASSWORD_ERROR) and $NEWPASSWORD_ERROR eq "TRUE"}{$newpass_error_message}{/if} -
- Confirm New Password: - - - {if isset($CNEWPASSWORD_ERROR) and $CNEWPASSWORD_ERROR eq "TRUE"}{$confirmnewpass_error_message}{/if} -
- {if isset($SUCCESS_PASS) and $SUCCESS_PASS eq "OK"} -

- The password has been changed! -

- {/if} - - - - - -

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

Change Email

- -
- - -
- New Email: - - - {if isset($EMAIL_ERROR) and $EMAIL_ERROR eq "TRUE"}{$EMAIL}{/if} -
- {if isset($SUCCESS_MAIL) and $SUCCESS_MAIL eq "OK"} -

- The email has been changed! -

- {/if} - - - -

- -

- -
-
-
-
- - - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php deleted file mode 100644 index 1b68ae4f0..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php +++ /dev/null @@ -1,327 +0,0 @@ -uId = $UId; - } - - - /** - * sets the object's attributes. - * @param $values should be an array. - */ - public function set($values){ - $this->uId = $values['uid']; - $this->login = $values['name']; - $this->email = $values['mail']; - //$this->firstname = $values['FirstName']; - //$this->lastname = $values['LastName']; - //$this->gender = $values['Gender']; - //$this->country = $values['Country']; - //$this->receiveMail = $values['ReceiveMail']; - //$this->language = $values['Language']; - } - - - /** - * function that checks if a username exists already or not. - * This function overrides the function of the base class. - * @param $username the username in question - * @return string Info: Returns 0 if the user is not in the web db, else a positive number is returned. - */ - protected function checkUserNameExists($username){ - return db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array(':name' => $username))->fetchField(); - } - - - /** - * function that checks if a email exists already or not. - * This function overrides the function of the base class. - * @param $email the email address in question. - * @return string Info: Returns 0 if the email address is not in the web db, else a positive number is returned. - */ - protected function checkEmailExists($email){ - return db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(':mail' => $email))->fetchField(); - } - - - /** - * check if the login username and password match the db. - * @param $username the inserted username - * @param $password the inserted password (unhashed) - * @return the logged in user's db row as array if login was a success, else "fail" will be returned. - */ - public static function checkLoginMatch($username,$password){ - if(!user_authenticate($username, $password)){ - return 'fail'; - }else{ - return db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc(); - } - } - - - /** - * returns te id for a given username - * @param $username the username - * @return the user's id linked to the username - */ - public static function getId($username){ - $row = db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc(); - return $row['uid']; - } - - - /** - * returns te id for a given emailaddress - * @param $email the emailaddress - * @return the user's id linked to the emailaddress - */ - public static function getIdFromEmail($email){ - $dbw = new DBLayer("web"); - $statement = $dbw->execute("SELECT * FROM ams_user WHERE Email=:email", array('email' => $email)); - $row = $statement->fetch(); - if(!empty($row)){ - return $row['UId']; - }else{ - return "FALSE"; - } - } - - - /** - * get uId attribute of the object. - */ - public function getUId(){ - return $this->uId; - } - - - /** - * get login attribute of the object.(username) - */ - public function getUsername(){ - - if(! isset($this->login) || $this->login == ""){ - $row = db_query("SELECT * FROM {users} WHERE uid = :id", array(':id' => $this->uId))->fetchAssoc(); - $this->set($row); - } - return $this->login; - } - - - /** - * get email attribute of the object. - */ - public function getEmail(){ - if(! isset($this->email) || $this->email == ""){ - $row = db_query("SELECT * FROM {users} WHERE uid = :id", array(':id' => $this->uId))->fetchAssoc(); - $this->set($row); - } - return $this->email; - } - - - /** - * get basic info of the object. - * @return returns an array in the form of Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country, 'ReceiveMail' => $this->receiveMail) - */ - public function getInfo(){ - $dbw = new DBLayer("web"); - if(! (isset($this->firstname) && isset($this->lastname) && isset($this->gender) && isset($this->country) && isset($this->receiveMail) ) || - $this->firstname == "" || $this->lastname == "" || $this->gender == "" || $this->country == "" || $this->receiveMail == ""){ - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); - $row = $statement->fetch(); - $this->set($row); - } - $result = Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country, 'ReceiveMail' => $this->receiveMail); - return $result; - } - - - /** - * get receiveMail attribute of the object. - */ - public function getReceiveMail(){ - $dbw = new DBLayer("web"); - if(! isset($this->receiveMail) || $this->receiveMail == ""){ - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); - $row = $statement->fetch(); - $this->set($row); - } - return $this->receiveMail; - } - - - /** - * get language attribute of the object. - */ - public function getLanguage(){ - return $DEFAULT_LANGUAGE; - } - - - /** - * check if the user is logged in. - * @return true or false - */ - public static function isLoggedIn(){ - if(isset($_SESSION['user'])){ - return true; - } - return false; - } - - - /** - * update the password. - * update the password in the shard + update the password in the www/CMS version. - * @param $user the username - * @param $pass the new password. - * @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline. - */ - public static function setPassword($user, $pass){ - $hashpass = crypt($pass, WebUsers::generateSALT()); - $reply = WebUsers::setAmsPassword($user, $hashpass); - $drupal_pass = user_hash_password($pass); - $values = Array('user' => $user, 'pass' => $drupal_pass); - try { - //make connection with and put into shard db - db_query("UPDATE {users} SET pass = :pass WHERE name = :user", $values); - } - catch (PDOException $e) { - //ERROR: the web DB is offline - } - return $reply; - } - - - /** - * update the emailaddress. - * update the emailaddress in the shard + update the emailaddress in the www/CMS version. - * @param $user the username - * @param $mail the new emailaddress. - * @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline. - */ - public static function setEmail($user, $mail){ - $reply = WebUsers::setAmsEmail($user, $mail); - $values = Array('user' => $user, 'mail' => $mail); - try { - //make connection with and put into shard db - db_query("UPDATE {users} SET mail = :mail WHERE name = :user", $values); - - } - catch (PDOException $e) { - //ERROR: the web DB is offline - } - return $reply; - } - - - /** - * update the setReceiveMail value in the db. - * update the receiveMail in the www/CMS version. - * @param $user the username - * @param $receivemail the receivemail setting . - */ - public static function setReceiveMail($user, $receivemail){ - $values = Array('user' => $user, 'receivemail' => $receivemail); - try { - //make connection with and put into shard db - $dbw = new DBLayer("web"); - $dbw->execute("UPDATE ams_user SET ReceiveMail = :receivemail WHERE UId = :user ",$values); - } - catch (PDOException $e) { - //ERROR: the web DB is offline - } - } - - - /** - * update the language value in the db. - * update the language in the www/CMS version. - * @param $user the username - * @param $language the new language value. - */ - public static function setLanguage($user, $language){ - $values = Array('user' => $user, 'language' => $language); - try { - //make connection with and put into shard db - $dbw = new DBLayer("web"); - $dbw->execute("UPDATE ams_user SET Language = :language WHERE UId = :user ",$values); - } - catch (PDOException $e) { - //ERROR: the web DB is offline - } - } - - - /** - * return all users. - * @return return an array of users - */ - public function getUsers(){ - $dbl = new DBLayer("web"); - $data = $dbl->executeWithoutParams("SELECT * FROM ams_user"); - return $data; - } - - - /** - * return the query that should get all users. - * @return string: the query to receive all users. - */ - public static function getAllUsersQuery(){ - return "SELECT * FROM users WHERE `uid` > 0"; - } - - - /** - * creates a webuser. - * it will set the language matching to the language cookie setting and add it to the www/CMS's DB. - * @param $name the username - * @param $pass the unhashed password - * @param $mail the email address - */ - public static function createWebuser($name, $pass, $mail){ - - //register account with the correct language (check if cookie is already set)! - if ( isset( $_COOKIE['Language'] ) ) { - $lang = $_COOKIE['Language']; - }else{ - global $DEFAULT_LANGUAGE; - $lang = $DEFAULT_LANGUAGE; - } - - $values = Array('name' => $name, 'pass' => $pass, 'mail' => $mail, 'lang' => $lang); - - try { - $dbw = new DBLayer("web"); - return $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Language) VALUES (:name, :pass, :mail, :lang)",$values); - } - catch (PDOException $e) { - //ERROR: the web DB is offline - } - } - -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.default.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.default.php deleted file mode 100644 index 1e2193bca..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/config.default.php +++ /dev/null @@ -1,111 +0,0 @@ -getInfo(); - if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && ($_GET['id']!= $_SESSION['id'])){ - $result['changesOther'] = "TRUE"; - } - $result['target_id'] = $_GET['id']; - $result['current_mail'] = $webUser->getEmail(); - $result['target_username'] = $webUser->getUsername(); - } - }else{ - $webUser = new Webusers($_SESSION['id']); - //$result = $webUser->getInfo(); - $result['target_id'] = $_SESSION['id']; - $result['current_mail'] = $webUser->getEmail(); - $result['target_username'] = $webUser->getUsername(); - - } - //Sanitize Data - $result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL); - $result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING); - //$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING); - //$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING); - //$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING); - //$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT); - //$result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT); - //$result['country_array'] = getCountryArray(); - global $INGAME_WEBPATH; - $result['ingame_webpath'] = $INGAME_WEBPATH; - return $result; - }else{ - //ERROR: not logged in! - header("Location: index.php"); - exit; - } -} - - -function getCountryArray(){ - -$countries = array( -'AA'=>'None Selected', -'AF'=>'Afghanistan', -'AL'=>'Albania', -'DZ'=>'Algeria', -'AS'=>'American Samoa', -'AD'=>'Andorra', -'AO'=>'Angola', -'AI'=>'Anguilla', -'AQ'=>'Antarctica', -'AG'=>'Antigua And Barbuda', -'AR'=>'Argentina', -'AM'=>'Armenia', -'AW'=>'Aruba', -'AU'=>'Australia', -'AT'=>'Austria', -'AZ'=>'Azerbaijan', -'BS'=>'Bahamas', -'BH'=>'Bahrain', -'BD'=>'Bangladesh', -'BB'=>'Barbados', -'BY'=>'Belarus', -'BE'=>'Belgium', -'BZ'=>'Belize', -'BJ'=>'Benin', -'BM'=>'Bermuda', -'BT'=>'Bhutan', -'BO'=>'Bolivia', -'BA'=>'Bosnia And Herzegovina', -'BW'=>'Botswana', -'BV'=>'Bouvet Island', -'BR'=>'Brazil', -'IO'=>'British Indian Ocean Territory', -'BN'=>'Brunei', -'BG'=>'Bulgaria', -'BF'=>'Burkina Faso', -'BI'=>'Burundi', -'KH'=>'Cambodia', -'CM'=>'Cameroon', -'CA'=>'Canada', -'CV'=>'Cape Verde', -'KY'=>'Cayman Islands', -'CF'=>'Central African Republic', -'TD'=>'Chad', -'CL'=>'Chile', -'CN'=>'China', -'CX'=>'Christmas Island', -'CC'=>'Cocos (Keeling) Islands', -'CO'=>'Columbia', -'KM'=>'Comoros', -'CG'=>'Congo', -'CK'=>'Cook Islands', -'CR'=>'Costa Rica', -'CI'=>'Cote D\'Ivorie (Ivory Coast)', -'HR'=>'Croatia (Hrvatska)', -'CU'=>'Cuba', -'CY'=>'Cyprus', -'CZ'=>'Czech Republic', -'CD'=>'Democratic Republic Of Congo (Zaire)', -'DK'=>'Denmark', -'DJ'=>'Djibouti', -'DM'=>'Dominica', -'DO'=>'Dominican Republic', -'TP'=>'East Timor', -'EC'=>'Ecuador', -'EG'=>'Egypt', -'SV'=>'El Salvador', -'GQ'=>'Equatorial Guinea', -'ER'=>'Eritrea', -'EE'=>'Estonia', -'ET'=>'Ethiopia', -'FK'=>'Falkland Islands (Malvinas)', -'FO'=>'Faroe Islands', -'FJ'=>'Fiji', -'FI'=>'Finland', -'FR'=>'France', -'FX'=>'France, Metropolitan', -'GF'=>'French Guinea', -'PF'=>'French Polynesia', -'TF'=>'French Southern Territories', -'GA'=>'Gabon', -'GM'=>'Gambia', -'GE'=>'Georgia', -'DE'=>'Germany', -'GH'=>'Ghana', -'GI'=>'Gibraltar', -'GR'=>'Greece', -'GL'=>'Greenland', -'GD'=>'Grenada', -'GP'=>'Guadeloupe', -'GU'=>'Guam', -'GT'=>'Guatemala', -'GN'=>'Guinea', -'GW'=>'Guinea-Bissau', -'GY'=>'Guyana', -'HT'=>'Haiti', -'HM'=>'Heard And McDonald Islands', -'HN'=>'Honduras', -'HK'=>'Hong Kong', -'HU'=>'Hungary', -'IS'=>'Iceland', -'IN'=>'India', -'ID'=>'Indonesia', -'IR'=>'Iran', -'IQ'=>'Iraq', -'IE'=>'Ireland', -'IL'=>'Israel', -'IT'=>'Italy', -'JM'=>'Jamaica', -'JP'=>'Japan', -'JO'=>'Jordan', -'KZ'=>'Kazakhstan', -'KE'=>'Kenya', -'KI'=>'Kiribati', -'KW'=>'Kuwait', -'KG'=>'Kyrgyzstan', -'LA'=>'Laos', -'LV'=>'Latvia', -'LB'=>'Lebanon', -'LS'=>'Lesotho', -'LR'=>'Liberia', -'LY'=>'Libya', -'LI'=>'Liechtenstein', -'LT'=>'Lithuania', -'LU'=>'Luxembourg', -'MO'=>'Macau', -'MK'=>'Macedonia', -'MG'=>'Madagascar', -'MW'=>'Malawi', -'MY'=>'Malaysia', -'MV'=>'Maldives', -'ML'=>'Mali', -'MT'=>'Malta', -'MH'=>'Marshall Islands', -'MQ'=>'Martinique', -'MR'=>'Mauritania', -'MU'=>'Mauritius', -'YT'=>'Mayotte', -'MX'=>'Mexico', -'FM'=>'Micronesia', -'MD'=>'Moldova', -'MC'=>'Monaco', -'MN'=>'Mongolia', -'MS'=>'Montserrat', -'MA'=>'Morocco', -'MZ'=>'Mozambique', -'MM'=>'Myanmar (Burma)', -'NA'=>'Namibia', -'NR'=>'Nauru', -'NP'=>'Nepal', -'NL'=>'Netherlands', -'AN'=>'Netherlands Antilles', -'NC'=>'New Caledonia', -'NZ'=>'New Zealand', -'NI'=>'Nicaragua', -'NE'=>'Niger', -'NG'=>'Nigeria', -'NU'=>'Niue', -'NF'=>'Norfolk Island', -'KP'=>'North Korea', -'MP'=>'Northern Mariana Islands', -'NO'=>'Norway', -'OM'=>'Oman', -'PK'=>'Pakistan', -'PW'=>'Palau', -'PA'=>'Panama', -'PG'=>'Papua New Guinea', -'PY'=>'Paraguay', -'PE'=>'Peru', -'PH'=>'Philippines', -'PN'=>'Pitcairn', -'PL'=>'Poland', -'PT'=>'Portugal', -'PR'=>'Puerto Rico', -'QA'=>'Qatar', -'RE'=>'Reunion', -'RO'=>'Romania', -'RU'=>'Russia', -'RW'=>'Rwanda', -'SH'=>'Saint Helena', -'KN'=>'Saint Kitts And Nevis', -'LC'=>'Saint Lucia', -'PM'=>'Saint Pierre And Miquelon', -'VC'=>'Saint Vincent And The Grenadines', -'SM'=>'San Marino', -'ST'=>'Sao Tome And Principe', -'SA'=>'Saudi Arabia', -'SN'=>'Senegal', -'SC'=>'Seychelles', -'SL'=>'Sierra Leone', -'SG'=>'Singapore', -'SK'=>'Slovak Republic', -'SI'=>'Slovenia', -'SB'=>'Solomon Islands', -'SO'=>'Somalia', -'ZA'=>'South Africa', -'GS'=>'South Georgia And South Sandwich Islands', -'KR'=>'South Korea', -'ES'=>'Spain', -'LK'=>'Sri Lanka', -'SD'=>'Sudan', -'SR'=>'Suriname', -'SJ'=>'Svalbard And Jan Mayen', -'SZ'=>'Swaziland', -'SE'=>'Sweden', -'CH'=>'Switzerland', -'SY'=>'Syria', -'TW'=>'Taiwan', -'TJ'=>'Tajikistan', -'TZ'=>'Tanzania', -'TH'=>'Thailand', -'TG'=>'Togo', -'TK'=>'Tokelau', -'TO'=>'Tonga', -'TT'=>'Trinidad And Tobago', -'TN'=>'Tunisia', -'TR'=>'Turkey', -'TM'=>'Turkmenistan', -'TC'=>'Turks And Caicos Islands', -'TV'=>'Tuvalu', -'UG'=>'Uganda', -'UA'=>'Ukraine', -'AE'=>'United Arab Emirates', -'UK'=>'United Kingdom', -'US'=>'United States', -'UM'=>'United States Minor Outlying Islands', -'UY'=>'Uruguay', -'UZ'=>'Uzbekistan', -'VU'=>'Vanuatu', -'VA'=>'Vatican City (Holy See)', -'VE'=>'Venezuela', -'VN'=>'Vietnam', -'VG'=>'Virgin Islands (British)', -'VI'=>'Virgin Islands (US)', -'WF'=>'Wallis And Futuna Islands', -'EH'=>'Western Sahara', -'WS'=>'Western Samoa', -'YE'=>'Yemen', -'YU'=>'Yugoslavia', -'ZM'=>'Zambia', -'ZW'=>'Zimbabwe' -); - -return $countries; - -} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_user.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_user.php deleted file mode 100644 index dc4548361..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_user.php +++ /dev/null @@ -1,46 +0,0 @@ -getUsername(); - $result['mail'] = $webUser->getEmail(); - //$info = $webUser->getInfo(); - //$result['firstName'] = $info['FirstName']; - //$result['lastName'] = $info['LastName']; - //$result['country'] = $info['Country']; - //$result['gender'] = $info['Gender']; - - $ticket_user = Ticket_User::constr_ExternId($result['target_id']); - $result['userPermission'] = $ticket_user->getPermission(); - if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ - $result['isAdmin'] = "TRUE"; - } - $ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId()); - - $result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category")); - global $INGAME_WEBPATH; - $result['ingame_webpath'] = $INGAME_WEBPATH; - return $result; - - }else{ - //ERROR: No access! - $_SESSION['error_code'] = "403"; - header("Location: index.php?page=error"); - exit; - } - }else{ - //ERROR: not logged in! - header("Location: index.php"); - exit; - } -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.info b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.info deleted file mode 100644 index f5e91be64..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.info +++ /dev/null @@ -1,11 +0,0 @@ -; $Id$ -name = Ryzom Account Manager -description = Ryzom Login Service Integration - inserts and updates users and manages accounts. -core = 7.x -package = Ryzom Plugins -configure = admin/settings/ryzommanage - -; Information added by drupal.org packaging script on 2012-04-24 -version = "7.x-.01" -core = "7.x" - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.install b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.install deleted file mode 100644 index 4575f2dbd..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.install +++ /dev/null @@ -1,31 +0,0 @@ - 'Ryzom Manager', - 'machine_name' => 'ryzommanage', - 'description' => 'Ryzom Login Service integration - inserts and updates users and manages accounts.', - 'module' => 'ryzommanage', - ); - $vocab = (object) $vocab; - db_query("CREATE TABLE ryzommanage_querycache ( - `SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `type` VARCHAR( 64 ) NOT NULL , - `query` VARCHAR( 512 ) NOT NULL - );"); - -} - -function ryzommanage_uninstall() { - db_query("DROP TABLE ryzommanage_querycache;"); -} - -function _ryzommanage_vocab_fields() { - -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module deleted file mode 100644 index 52faa4c56..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module +++ /dev/null @@ -1,1034 +0,0 @@ - ring users ---- nel user & nel permission ---- hook_user_cancel ---- remove character data on server -menu items that do stuff - -*/ -error_reporting(E_ALL); -ini_set('display_errors', 'on'); -ini_set('display_startup_errors', TRUE); - -//load globals before requiring them -global $TOS_URL; -global $AMS_LIB; -global $SITEBASE; -global $AMS_TRANS; -global $DEFAULT_LANGUAGE; -global $cfg; -global $TICKET_LOGGING; -global $TIME_FORMAT; -global $TICKET_MAILING_SUPPORT; -global $IMAGELOC_WEBPATH; -global $WEBPATH; -global $INGAME_WEBPATH; -global $BASE_WEBPATH; -global $INGAME_LAYOUT; -global $FORCE_INGAME; - -//require additional pages & register the autoload function. -require 'config.php'; -require 'ams_lib/libinclude.php'; -spl_autoload_register('__autoload'); - -/* -Drupal 7 ryzom core module -Copyright (C) 2013 Matthew Lagoe (Botanic) & Paige Offerdahl (Tobi) - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ -//output template - -function loadTemplate($template,$vars) -{ - extract($vars); - include($template); -} - -//validate registration webpage -function ryzommanage_form_alter(&$form, &$form_state, $form_id) -{ - if($form_id == "user_register_form") - { - $form['#validate'][] = '_webpage_registration'; - } elseif($form_id == "user_profile_form") { - $form['#validate'][] = '_webpage_profile'; - } -} - -function _webpage_registration(&$form_state) -{ - $webUser = new WebUsers(); - $user = $webUser->checkUser($form_state['account']['name']['#value']); - $email = $webUser->validEmail($form_state['account']['mail']['#value']); - - if ($user != "success") { - form_set_error('name', t($user)); - } - if ($email != "success") { - form_set_error('mail', t('Not a valid email address, please check it and try again.')); - } - -} - -function _webpage_profile(&$form_state) -{ - $webUser = new WebUsers(); - $email = $webUser->validEmail($form_state['account']['mail']['#value']); - - if ($email != "success") { - form_set_error('mail', t('Not a valid email address, please check it and try again.')); - } - if (($webUser->checkPassword($form_state['account']['pass']['#value']['pass1']) == "success" ) and ( $form_state['account']['pass']['#value']['pass1'] == - $form_state['account']['pass']['#value']['pass2'] )) { - } -} - -/** - * - * Function ryzommanage_menu - * - * @takes Nothing - * @return array $items - * - * Info: Creates the menu item in the admin interface - * - */ -function ryzommanage_menu() -{ - $items = array(); - //page for client registration - $items['register'] = array( - 'title' => 'register', - 'page callback' => '_collect_register', - 'page arguments' => array(1, 2), - 'access callback' => 'user_access', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK - ); - - $items['login'] = array( - 'title' => 'Login', - 'page callback' => '_collect_login', - 'page arguments' => array(1, 2), - 'access callback' => 'user_access', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK - ); - - $items['ams'] = array( - 'title' => 'Ryzom Account Management System', - 'page callback' => '_ams_callback', - 'access callback' => 'user_access', - 'access arguments' => array('access content'), - 'type' => MENU_NORMAL_ITEM - ); - - $items['ingame'] = array( - 'title' => 'Ingame AMS', - 'page callback' => '_collect_ingame_ams', - 'page arguments' => array(1, 2), - 'access callback' => 'user_access', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK - ); - - //main menu item - $items['admin/config/ryzommanage'] = array( - 'title' => 'Ryzom Server Integration', - 'description' => 'Ryzom integration information.', - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array( - 'administer site configuration' - ), - 'file' => 'system.admin.inc', - 'file path' => drupal_get_path('module', 'system') - ); - // First submenu item - $items['admin/config/ryzommanage/serversettings'] = array( - 'title' => 'Ryzom Server Settings', - 'description' => 'This is the first child item in the section', - 'page callback' => 'drupal_get_form', - 'page arguments' => array( - 'ryzommanage_admin' - ), - 'access arguments' => array( - 'administer site configuration' - ) - ); - // Second submenu item - $items['admin/config/ryzommanage/nameregister'] = array( - 'title' => 'Name Registration Settings', - 'description' => 'Configure default behavior of name registration module.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array( - 'name_registration_admin_settings' - ), - 'access arguments' => array( - 'administer site configuration' - ) - ); - return $items; -} - -//an empty call back function, because we need an empty page! -//without this the page gets access denied, perhaps for later use.. -function _ams_callback(){ - return array(); -} - -/** - * - * Function ryzommanage_menu - * - * @takes Int $element, &$form_state - * @return Nothing - * - * Info: Used by ryzommanage_mysqlport to validate ryzommanage_admin will run form_error if port is not between 1 and 65535. - * - */ -function _check_port_value($element, &$form_state) -{ - if ((!is_numeric(parse_size($element['#value']))) or ((parse_size($element['#value']) > 65535) or (parse_size($element['#value']) < 1))) { - form_error($element, t($element['#value'] . ' is not a valid value for the MySQL port, it must be a valid value. You must choose a number between 1 and 65535.')); - } -} -/** - * - * Function ryzommanage_block_info - * - * @takes Nothing - * @return array $blocks - * - * Info: Info for block that shows the user menu - * - */ -function ryzommanage_block_info() -{ - $blocks['ryzommanage_usersblock'] = array( - // info: The name of the block. - 'info' => t('Ryzom Manage User Block'), - 'status' => TRUE, - 'region' => '-1', // Not usually provided. - 'visibility' => BLOCK_VISIBILITY_LISTED // Not usually provided. - ); - - $blocks['ryzommanage_amsblock'] = array( - // info: The name of the block. - 'info' => t('Ryzom AMS Block'), - 'status' => TRUE, - 'region' => '-1', // Not usually provided. - 'visibility' => BLOCK_VISIBILITY_LISTED, - 'pages' => 'ams' - ); - return $blocks; -} -/** - * - * Function ryzommanage_block_view - * - * @takes Nothing - * @return array $block - * - * Info: View for block - * - */ -function ryzommanage_block_view($delta = '') -{ - $block = array(); - //The $delta parameter tells us which block is being requested. - switch ($delta) { - case 'ryzommanage_usersblock': - $block['subject'] = t("uppercase this please"); - $block['content'] = top_bar(); - break; - - case 'ryzommanage_amsblock': - //$block['subject'] = t("Ryzom Account Management System"); - $block['content'] = _ams_handler(); - break; - } - return $block; -} - - - -/* -* Core function, similar to the www index.php version. -*/ -function _ams_handler($ingame = false) -{ - global $BASE_WEBPATH; - global $SITEBASE; - global $INGAME_WEBPATH; - - //Decide what page to load - if ( ! isset( $_GET["page"]) ){ - if(isset($_SESSION['user'])){ - if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ - $page = 'dashboard'; - }else{ - $page = 'show_user'; - } - }else{ - //default page - if($ingame){ - header("Location: ".$INGAME_WEBPATH."?page=login"); - }else{ - header("Location: ".$BASE_WEBPATH."/user/login"); - } - exit; - } - }else{ - $page = $_GET["page"]; - } - - //perform an action in case one is specified - //else check if a php page is included in the inc folder, else just set page to the get param - if ( isset( $_POST["function"] ) ){ - $filename = $SITEBASE . '/func/' . $_POST["function"] . '.php'; - if(is_file($filename)){ - require($filename); - $return = $_POST["function"](); - } - }else{ - $filename = $SITEBASE . '/inc/' . $page . '.php'; - if(is_file($filename)){ - require_once($filename); - $return = $page(); - } - } - - //add username to the return array in case logged in. - if(isset($_SESSION['user'])){ - $return['username'] = $_SESSION['user']; - } - - //Set permission - if(isset($_SESSION['ticket_user'])){ - $return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); - }else{ - //default permission - $return['permission'] = 0; - } - - //handle error page - if($page == 'error'){ - $return['permission'] = 0; - $return['no_visible_elements'] = 'FALSE'; - } - - //return $page; - if ($ingame){ - helpers :: loadTemplate( $page , $return ); - }else{ - return helpers :: loadTemplate( $page , $return, true); - } - -} - - - -/** - * - * Function _collect_register - * - * @takes - * @return Nothing - * - * Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to / - * - */ -function _collect_register($nids, $collection) -{ - Sync::syncdata(); - //if not using ryzom core client show registration page - if (Helpers::check_if_game_client()) { - return_client_httpdata(); - } else { - //redirect to registration page - global $BASE_WEBPATH; - header("Location: ".$BASE_WEBPATH. "/user/register"); - } -} - - - -/** - * - * Function _collect_ingame_ams - * - * @takes - * @return Nothing - * - * Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to / - * - */ -function _collect_ingame_ams($nids, $collection) -{ - //if not using ryzom core client show registration page - if (Helpers::check_if_game_client()) { - _ams_handler(true); - } else { - //redirect to registration page - global $WEBPATH; - header("Location: ". $WEBPATH); - } -} - - -/** - * - * Function _collect_register - * - * @takes - * @return Nothing - * - * Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to / - * - */ -function _collect_login($nids, $collection) -{ - global $WEBPATH; - global $BASE_WEBPATH; - $result = Helpers::check_login_ingame(); - if ($result != "FALSE") { - //handle successful ingame login - $_SESSION['user'] = $result['name']; - $_SESSION['id'] = WebUsers::getId($result['name']); - $_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id'])); - - if ($account = user_load( $_SESSION['id'])) { - global $user; - $user->uid = $_SESSION['id']; - $user->name = $account->name; - $user->timezone = $account->timezone; - user_login_finalize(); - } - header( 'Location: '.$WEBPATH ); - } else { - //redirect to registration page - header("Location: ".$BASE_WEBPATH."/user/login"); - } -} - - -/** - * - * Function confirmPassword - * - * @takes $pass - * @return string - * - * Info: Verify's $_POST["Password"] is the same as $_POST["ConfirmPass"] - * - */ -function confirmPassword() -{ - if (($_POST["Password"]) != ($_POST["ConfirmPass"])) { - return "Passwords do not match."; - } else { - return "success"; - } - return "fail"; -} - - -/** - * - * Function ryzommanage_user_insert - * - * @takes $pass - * @return string - * - * Info: Hook that's being called after creating a drupal user, we need to do it like this to access the drupals newly created user's id. - * - */ -function ryzommanage_user_insert(&$edit, $account, $category){ - if (isset($edit['unhashpass'])) { - $pass = $edit['unhashpass']; - } elseif (isset($_POST['pass']['pass1'])) { - $pass = $_POST['pass']['pass1']; - } - createUser(array($edit['name'], $pass, $edit['mail']), $account->uid); -} - -function createUser($values, $user_id) -{ - - $login = $values[0]; - $pass = $values[1]; - $email = $values[2]; - - /*$salt = generateSALT(); - $hashpass = crypt($pass, $salt);*/ - - $hashpass = crypt($pass, WebUsers::generateSALT()); - - $params = array( - 'name' => $login, - 'pass' => $hashpass, - 'mail' => $email - ); - - //Create the user on the shard + in case shard is offline put copy of query in query db - //returns: ok, shardoffline or liboffline - $result = WebUsers::createUser($params, $user_id); - Users::createPermissions(array($login)); -} - -/*function createPermissions($values) { - - try { - $hostname = variable_get('ryzommanage_serverurl', 'localhost'); - $port = variable_get('ryzommanage_mysqlport', '3306'); - $dbname = variable_get('ryzommanage_dbname', 'nel'); - $username = variable_get('ryzommanage_username', 'root'); - $password = variable_get('ryzommanage_password', ''); - $dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createPermissions", - "query" => json_encode(array( - $values[0] - )) - ))->execute(); - return true; - } - - try { - $sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';"); - $sth->execute(); - $result = $sth->fetchAll(); - foreach ($result as $UId) { - $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'r2', 'OPEN');"); - $statement->execute($values); - $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'ryzom_open', 'OPEN');"); - $statement->execute($values); - } - } - catch (PDOException $e) { - watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); - $nid = db_insert('ryzommanage_querycache')->fields(array( - "SID" => NULL, - "type" => "createPermissions", - "query" => json_encode(array( - $values[0] - )) - ))->execute(); - return true; - } - - return true; -}*/ - -function ryzommanage_user_login(&$edit, $account){ - $_SESSION['user'] = $account->name; - $_SESSION['id'] = $account->uid; - $_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id'])); -} - -function login_form($login_form) -{ - $login_form['#action'] = url(current_path(), array( - 'query' => drupal_get_destination(), - 'external' => FALSE - )); - $login_form['#id'] = 'user-login-form'; - $login_form['#validate'] = user_login_default_validators(); - $login_form['#submit'][] = 'user_login_submit'; - $login_form['name'] = array( - '#type' => 'textfield', - '#title' => t('Username'), - '#maxlength' => 12, - '#size' => 15, - '#required' => TRUE - ); - $login_form['pass'] = array( - '#type' => 'password', - '#title' => t('Password'), - '#maxlength' => 20, - '#size' => 15, - '#required' => TRUE - ); - $items = array(); - if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { - $items[] = l(t('Create new account'), 'user/register', array( - 'attributes' => array( - 'title' => t('Create a new user account.') - ) - )); - } - $items[] = l(t('Request new password'), 'user/password', array( - 'attributes' => array( - 'title' => t('Request new password via e-mail.') - ) - )); - $login_form['links'] = array( - '#markup' => theme('item_list', array( - 'items' => $items - )) - ); - $login_form['remember_me'] = array( - '#type' => 'checkbox', - '#title' => t('Remember Me'), - '#default_value' => 0 - ); - $login_form['actions'] = array( - '#type' => 'actions' - ); - $login_form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Log in') - ); - return $login_form; -} - -function top_bar() -{ - global $user; - global $WEBPATH; - global $BASE_WEBPATH; - $userId = $user->uid; - if (user_is_logged_in()) { - // Logged in user - //check permission, if user - if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){ - return ""; - - }else{ - return ""; - } - - } else { - return drupal_get_form('login_form'); - // Not logged in - } -} - - - -function ryzommanage_user_presave(&$edit, $account, $category) -{ - if (isset($edit['unhashpass'])) { - $pass = $edit['unhashpass']; - } elseif (isset($_POST['pass']['pass1'])) { - $pass = $_POST['pass']['pass1']; - } - - if (!isset($edit['name'])) { - $name = $user->name; - } else { - $name = $edit['name']; - } - - if ($account->is_new == 1 ) { - //createUser(array($edit['name'], $pass, $edit['mail'])); - } else { - user_edit( array($edit['name'], $pass)); - } -} - -function ryzommanage_form_user_register_form_alter(&$form, &$form_state, $form_id) { - // Modification for the form with the given form ID goes here. For example, if - // FORM_ID is "user_register_form" this code would run only on the user - // registration form. - - // Change the data for the username and email fields - $form['account']['name']['#maxlength'] = '12'; - $form['account']['name']['#description'] = '5-12 lower-case characters and numbers. The login (username) you create here will be your login name.
The name of your game characters will be chosen later on.
'; - $form['account']['mail']['#description'] = 'Please verify that the e-mail address you enter here is valid and will remain valid in the future.
It will be used to manage your Tempest in the Aether account.
'; - // Add a checkbox to registration form about agreeing to terms of use. - $form['terms_of_use'] = array( - '#type' => 'checkbox', - '#title' => t("I agree with the terms and conditions."), - '#required' => TRUE, - ); - -} - -function ryzommanage_form_user_profile_form_alter(&$form, &$form_state, $form_id) { - // Modification for the form with the given form ID goes here. For example, if - // FORM_ID is "user_register_form" this code would run only on the user - // registration form. - - // Change the data for the password field - $form['account']['pass']['#description'] = 'Password must be 5-20 characters.
'; -} - -function user_edit($values) { - - $username = $values[0]; - $newpassword = $values[1]; - - $salt = WebUsers::generateSALT(); - $pass = crypt($newpassword, $salt); - - $webUser = new WebUsers(); - $webUser->setAmsPassword($username,$pass); - return true; -} - - -/** - * - * Function ryzommanage_cron - * - * @takes - * @return - * - * Info: Runs the syncdata function with the drupal cron - * - */ -function ryzommanage_cron() { - - Sync::syncdata(); - -} - -function name_registration_admin_settings() { - global $TOS_URL; - $form = array(); - $form['ryzommanage_game-name'] = array( - '#type' => 'textfield', - '#title' => t('Game Name'), - '#default_value' => variable_get('ryzommanage_game-name', ''), - '#description' => t("Name of game used on registration pages."), - '#required' => TRUE - ); - //this is not the TOS url used in the create account page, you change that in the config of the client with the ConditionsTermsURL value - $form['ryzommanage_TOS'] = array( - '#type' => 'textfield', - '#title' => t('Terms of Service URL'), - '#default_value' => $TOS_URL, - '#description' => t("The url of the TOS for your server."), - '#required' => TRUE - ); - $form['ryzommanage_register-welcome'] = array( - '#type' => 'textarea', - '#title' => t('Registration Welcome Message'), - '#default_value' => variable_get('ryzommanage_register-welcome', ''), - '#description' => t("Registration welcome message on first page of create account."), - '#required' => TRUE - ); - - return system_settings_form($form); -} - - -/** - * - * Function ryzommanage_admin - * - * @takes Nothing - * @return array $form - * - * Info: Creates the box's etc that go in the ryzom admin menu - * - */ -function ryzommanage_admin() -{ - $form = array(); - //admin menu items - global $cfg; - - $form['ryzommanage_shardserverurl'] = array( - '#type' => 'textfield', - '#title' => t('Shard server url'), - '#default_value' => $cfg['db']['shard']['host'], - '#description' => t("The url of the ryzom server to integrate with."), - '#required' => TRUE - ); - $form['ryzommanage_shardmysqlport'] = array( - '#type' => 'textfield', - '#title' => t('Port for MySQL of the Shard'), - '#size' => 5, - '#maxlength' => 5, - '#default_value' => $cfg['db']['shard']['port'], - '#description' => t("The MySQL port of the ryzom server to integrate with."), - '#required' => TRUE, - '#element_validate' => array( - '_check_port_value' - ) - ); - $form['ryzommanage_sharddbname'] = array( - '#type' => 'textfield', - '#title' => t('Shard Database Name'), - '#default_value' => $cfg['db']['shard']['name'], - '#description' => t("The MySQL database name to connect to."), - '#required' => TRUE - ); - $form['ryzommanage_shardusername'] = array( - '#type' => 'textfield', - '#title' => t('Shard MySQL Username'), - '#default_value' => $cfg['db']['shard']['user'], - '#description' => t("The MySQL username to connect with."), - '#required' => TRUE - ); - $form['ryzommanage_shardpassword'] = array( - '#type' => 'password_confirm', - '#title' => t('Shard MySQL Password'), - '#description' => t("Confirm the MySQL password."), - '#suffix' => '
' - ); - - $form['ryzommanage_libserverurl'] = array( - '#type' => 'textfield', - '#title' => t('Lib server url'), - '#default_value' => $cfg['db']['lib']['host'], - '#description' => t("The url of the ryzom's lib db to integrate with."), - '#required' => TRUE - ); - $form['ryzommanage_libmysqlport'] = array( - '#type' => 'textfield', - '#title' => t('Port for MySQL of the Lib'), - '#size' => 5, - '#maxlength' => 5, - '#default_value' => $cfg['db']['lib']['port'], - '#description' => t("The MySQL port of the ryzom's lib db to integrate with."), - '#required' => TRUE, - '#element_validate' => array( - '_check_port_value' - ) - ); - $form['ryzommanage_libdbname'] = array( - '#type' => 'textfield', - '#title' => t('Lib Database Name'), - '#default_value' => $cfg['db']['lib']['name'], - '#description' => t("The MySQL database name to connect to."), - '#required' => TRUE - ); - $form['ryzommanage_libusername'] = array( - '#type' => 'textfield', - '#title' => t('Lib MySQL Username'), - '#default_value' => $cfg['db']['lib']['user'], - '#description' => t("The MySQL username to connect with."), - '#required' => TRUE - ); - $form['ryzommanage_libpassword'] = array( - '#type' => 'password_confirm', - '#title' => t('Lib MySQL Password'), - '#description' => t("Confirm the MySQL password."), - '#suffix' => '
' - ); - - - $form['ryzommanage_ringserverurl'] = array( - '#type' => 'textfield', - '#title' => t('Ring server url'), - '#default_value' => $cfg['db']['ring']['host'], - '#description' => t("The url of the ryzom's ring db to integrate with."), - '#required' => TRUE - ); - $form['ryzommanage_ringmysqlport'] = array( - '#type' => 'textfield', - '#title' => t('Port for MySQL of the Lib'), - '#size' => 5, - '#maxlength' => 5, - '#default_value' => $cfg['db']['ring']['port'], - '#description' => t("The MySQL port of the ryzom ring db to integrate with."), - '#required' => TRUE, - '#element_validate' => array( - '_check_port_value' - ) - ); - $form['ryzommanage_ringdbname'] = array( - '#type' => 'textfield', - '#title' => t('Ring Database Name'), - '#default_value' => $cfg['db']['ring']['name'], - '#description' => t("The MySQL database name to connect to."), - '#required' => TRUE - ); - $form['ryzommanage_ringusername'] = array( - '#type' => 'textfield', - '#title' => t('Ring MySQL Username'), - '#default_value' => $cfg['db']['ring']['user'], - '#description' => t("The MySQL username to connect with."), - '#required' => TRUE - ); - $form['ryzommanage_ringpassword'] = array( - '#type' => 'password_confirm', - '#title' => t('Ring MySQL Password'), - '#description' => t("Confirm the MySQL password.") - ); - return system_settings_form($form); -} - -/** - * - * Function return_client_httpdata - * - * @takes - * @return - * - * Info: Returns ryzom core formatted html for use in registration via client - * - */ -function return_client_httpdata() -{ - //needs $cpass = confirmPassword(($_POST["Password"]) != ($_POST["ConfirmPass"])); !!!!!! - //check if values exist - if (isset($_POST["Username"]) and isset($_POST["Password"]) and isset($_POST["Email"]) ) - { - //check values - $user = checkUser($_POST["Username"]); - $pass = checkPassword($_POST["Password"]); - $cpass = confirmPassword(($_POST["Password"]) != ($_POST["ConfirmPass"])); - $email = checkEmail($_POST["Email"]); - } else { - $user = ""; - $pass = ""; - $cpass = ""; - $email = ""; - } - //if all are good then create user - if (($user == "success") and ($pass == "success") and ($cpass == "success") and ($email == "success") and (isset($_POST["TaC"]))) { - $edit = array( - 'name' => $_POST["Username"], - 'pass' => $_POST["Password"], - 'mail' => $_POST["Email"], - 'init' => $_POST["Email"], - 'unhashpass' => $_POST["Password"], - 'status' => 1, - 'access' => REQUEST_TIME - ); - user_save(NULL, $edit); - header('Location: email_sent.php'); - exit; - } else { - $pageElements = array( - 'GAME_NAME' => variable_get('ryzommanage_game-name', ''), - 'WELCOME_MESSAGE' => variable_get('ryzommanage_register-welcome', ''), - 'USERNAME' => $user, - 'PASSWORD' => $pass, - 'CPASSWORD' => $cpass, - 'EMAIL' => $email - ); - if ($user != "success") { - $pageElements['USERNAME_ERROR'] = 'TRUE'; - } else { - $pageElements['USERNAME_ERROR'] = 'FALSE'; - } - - if ($pass != "success") { - $pageElements['PASSWORD_ERROR'] = 'TRUE'; - } else { - $pageElements['PASSWORD_ERROR'] = 'FALSE'; - } - if ($cpass != "success") { - $pageElements['CPASSWORD_ERROR'] = 'TRUE'; - } else { - $pageElements['CPASSWORD_ERROR'] = 'FALSE'; - } - if ($email != "success") { - $pageElements['EMAIL_ERROR'] = 'TRUE'; - } else { - $pageElements['EMAIL_ERROR'] = 'FALSE'; - } - if (isset($_POST["TaC"])) { - $pageElements['TAC_ERROR'] = 'FALSE'; - } else { - $pageElements['TAC_ERROR'] = 'TRUE'; - } - loadTemplate('templates/ingame_register.phtml',$pageElements); - } -} - -/** -* Implements hook_help. -* -* Displays help and module information. -* -* @param path -* Which path of the site we're using to display help -* @param arg -* Array that holds the current path as returned from arg() function -*/ -function ryzommanage_help($path, $arg) { - switch ($path) { - case "admin/help#ryzommanage": - return '

' . t("A module that handles account registration and a ticketing service regarding ryzomcore.") . '

'; - break; - } -} - -function ryzommanage_enable() { - // Check if our field is not already created. - if (!field_info_field('firstname')) { - $field = array( - 'field_name' => 'firstname', - 'type' => 'text', - ); - field_create_field($field); - - // Create the instance on the bundle. - $instance = array( - 'field_name' => 'firstname', - 'entity_type' => 'user', - 'label' => 'First Name', - 'bundle' => 'user', - // If you don't set the "required" property then the field wont be required by default. - 'required' => FALSE, - 'settings' => array( - // Here you inform either or not you want this field showing up on the registration form. - - ), - 'widget' => array( - 'type' => 'textfield', - 'weight' => '1', - ), - ); - field_create_instance($instance); - } - - if (!field_info_field('secondname')) { - $field = array( - 'field_name' => 'secondname', - 'type' => 'text', - ); - field_create_field($field); - - // Create the instance on the bundle. - $instance = array( - 'field_name' => 'secondname', - 'entity_type' => 'user', - 'label' => 'Second Name', - 'bundle' => 'user', - // If you don't set the "required" property then the field wont be required by default. - 'required' => FALSE, - 'settings' => array( - // Here you inform either or not you want this field showing up on the registration form. - ), - 'widget' => array( - 'type' => 'textfield', - 'weight' => '1', - ), - ); - field_create_instance($instance); - } -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/createticket.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/createticket.tpl deleted file mode 100644 index c1ca81e07..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/createticket.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{block name=content} - -

Create a new Ticket

-
- - - - - - - - - - - - - -
- - -
- - -
- - -
- - - -
-
-{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/dashboard.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/dashboard.tpl deleted file mode 100644 index 83def588a..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/dashboard.tpl +++ /dev/null @@ -1,77 +0,0 @@ -{block name=content} - - - - - - - - - - - -
- -
Tickets Waiting for Direct Action: - {$nrAssignedWaiting}
-
-
- -
Tickets Todo: - {$nrToDo}
-
-
- - -
Newest Ticket: - {$newestTicketTitle}
-
-
- - -
Total amount of Tickets: - {$nrTotalTickets}
-
-
- -
-
-
-

{$home_title}

-
- - - - -
-
-
-

{$home_info}

-

This is the GSOC project of Daan Janssens mentored by Matthew Lagoe.

-

The features as admin covered in this project are:

-
    -
  • Manage user accounts
  • -
  • Make users moderator or admin
  • -
  • browse user's tickets
  • -
  • Create a new ticket for a specific user as admin
  • -
  • Create a new support group (and link an email to it)
  • -
  • Add mods to support groups
  • -
  • Assign ticket to you
  • -
  • Forward ticket to a support group
  • -
  • Add hidden messages to a ticket only viewable by other mods
  • -
  • Browse ticket queues or create one dynamically
  • -
  • Sync changes after the game server is back up after being down for a while
  • -
  • Browse the log of a ticket
  • -
  • Browse additional info sent along when a ticket is created ingame
  • -
  • All the above can be done while ingame too
  • -
- -
-
-
-
- - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/ingame_register.phtml b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/ingame_register.phtml deleted file mode 100644 index 1f0fc0859..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/ingame_register.phtml +++ /dev/null @@ -1,116 +0,0 @@ -
- RYZOM CORE INGAME REGISTRATION -
- -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You must accept the Terms of Service';} - else { - echo ' -
id="caption-Username">Desired Username: - - width="42%">
id="caption-Password">Desired Password: - - width="42%">
id="caption-ConfirmPass">Confirm Password: - width="42%">
id="caption-Email">Email Address (to which a confirmation email will be sent): - account.', this);" /> - width="42%">
- colspan="2">YES, I agree to the terms of - service';}; ?> -
- -
- -
-
- -
- -
- 5-12 lower-case characters and numbers. The login (username) you create here will be - your login name. The name of your game characters will be chosen later on. -
- -
- 5-20 characters. -
- -
- Retype your Password -
- -
- Please verify that the e-mail address you enter here is valid and will remain valid - in the future. It will be used to manage your account. -
- -
\ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout.tpl deleted file mode 100644 index f889a43a6..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout.tpl +++ /dev/null @@ -1,2 +0,0 @@ -{block name=content}{/block} - \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_admin.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_admin.tpl deleted file mode 100644 index 881ccb18a..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_admin.tpl +++ /dev/null @@ -1,2 +0,0 @@ -{extends file="layout.tpl"} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_mod.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_mod.tpl deleted file mode 100644 index c5ed6c10b..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_mod.tpl +++ /dev/null @@ -1,3 +0,0 @@ -{extends file="layout.tpl"} - - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_user.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_user.tpl deleted file mode 100644 index 62185e613..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/layout_user.tpl +++ /dev/null @@ -1 +0,0 @@ -{extends file="layout.tpl"} diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/sgroup_list.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/sgroup_list.tpl deleted file mode 100644 index 231250fda..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/sgroup_list.tpl +++ /dev/null @@ -1,105 +0,0 @@ -{block name=content} - -

List of all Support Groups

- - - - - - - - - {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} - - - - {foreach from=$grouplist item=group} - - - - - - {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} - - {/foreach} - - -
IDNameTagEmailAction
{$group.sGroupId}{$group.name}{$group.tag}{$group.groupemail}Delete
- - {if isset($isAdmin) && $isAdmin eq 'TRUE'} - -

Add a support group

- -
- - - - - - - - - - -
- - - - - - -
- - - - - - - - -
-
- - - - - - -
- - - - - - - - -
-
- - -
- - -
- {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} - -

{$group_success}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"} - -

{$group_name_taken}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"} - -

{$group_tag_taken}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"} - -

{$group_size_error}

-
- {/if} - - {/if} -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_queue.tpl deleted file mode 100644 index 2a274f47e..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_queue.tpl +++ /dev/null @@ -1,204 +0,0 @@ -{block name=content} -

Ticket Queue {$queue_view}

- - - - - - - - - - - - - - - - - -
- - - - - - - - -
Todo ticketsAll ticketsAll open ticketsTicket ArchiveNot Assigned Tickets
-
-
- - - - - - - -
- - - - - - - - - - - -
- Show - - - - tickets - - - - to - - - - - - - - - - -
-
- - -
-
-
- {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} - - {$success_assigned} - - {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} - - {$success_unassigned} - - {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} - - {$ticket_not_existing} - - {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} - - {$ticket_already_assigned} - - {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} - - {$ticket_not_assigned} - - {/if} -
- - - - - - - - - - - - - - - {foreach from=$tickets item=ticket} - - - - - - - - - - - {/foreach} - - -
IDTitleAssignedTimestampCategoryStatusSupportGroupActions
{$ticket.tId}{$ticket.title}{if $ticket.assignedText neq ""} {$ticket.assignedText} {else} {$not_assigned} {/if}{$ticket.timestamp}{$ticket.category} {$ticket.statusText} - - {if $ticket.forwardedGroupName eq "0"} - {$public_sgroup} - {else} - {$ticket.forwardedGroupName} - {/if} - - - {if $ticket.assigned eq 0} -
- - - -
- {else if $ticket.assigned eq $user_id} -
- - - -
- {/if} -
- -
- « | - {foreach from=$links item=link} - {if $link == $currentPage}{/if}{$link}{if $link == $currentPage}{/if} | - {/foreach} - » -
-
- - - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl deleted file mode 100644 index 287d59f8b..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_reply.tpl +++ /dev/null @@ -1,24 +0,0 @@ -{block name=content} -

Show Reply

- -

Reply ID#{$reply_id} of Ticket #{$ticket_id}

- - - - -
-

{$reply_timestamp} - {if $author_permission eq '1'} - {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if}

- {else if $author_permission gt '1'} - {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if}

- {/if} -

{if $hidden eq 1}{/if}{$reply_content}{if $hidden eq 1}{/if}

- -
- - - - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl deleted file mode 100644 index 0f1d55d17..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_sgroup.tpl +++ /dev/null @@ -1,118 +0,0 @@ -{block name=content} - -

{$groupsname} Members List

- - - - - - {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} - - - - - {foreach from=$userlist item=user} - - - - {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} - - {/foreach} - - -
IDNameAction
{$user.tUserId}{$user.name} Delete
- - {if isset($isAdmin) && $isAdmin eq 'TRUE'} -

Add user to '{$groupsname}'

- - - - -
-
- - - - - -
-
- - - - {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} - -

{$add_to_group_success}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "ALREADY_ADDED"} - -

{$user_already_added}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "GROUP_NOT_EXISTING"} - -

{$group_not_existing}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "USER_NOT_EXISTING"} - -

{$user_not_existing}

-
- {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NOT_MOD_OR_ADMIN"} - -

{$not_mod_or_admin}

-
- {/if} - - -

Modify Email Settings

-
- - - - - - - - - - - - - -
- - - - - -
- - - - - -
- - - -
-
- - {if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "SUCCESS"} - - {$modify_mail_of_group_success} - - {else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "EMAIL_NOT_VALID"} - - {$email_not_valid} - - {else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "NO_PASSWORD"} - - {$no_password_given} - - {/if} - - - {/if} - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl deleted file mode 100644 index 5a4963795..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket.tpl +++ /dev/null @@ -1,188 +0,0 @@ -{block name=content} -

Title: {$ticket_title} [ID#{$ticket_tId}]

- - - - {if isset($isMod) and $isMod eq "TRUE"} - - - {/if} - {if isset($isMod) and $isMod eq "TRUE"}{/if} - - - {if $hasInfo}{/if} - - -
- Ticket Assigning: - {if $ticket_assignedTo eq 0} -
- - - -
- {else if $ticket_assignedTo eq $user_id} -
- - - -
- {/if} -
- Forward to Group: -
- - - - -
-
Show Ticket LogSend Other TicketShow ticket Info
- - - - {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} - -

{$success_assigned}

-
- {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} - -

{$success_unassigned}

-
- {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} - -

{$ticket_not_existing}

-
- {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} - -

{$ticket_already_assigned}

-
- {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} - -

{$ticket_not_assigned}

-
- {/if} - - {if isset($ACTION_RESULT) and $ACTION_RESULT eq "INVALID_SGROUP"} - -

{$invalid_sgroup}

-
- {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} - -

{$ticket_not_existing}

-
- {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_FORWARDED"} - -

{$success_forwarded}

-
- {/if} - -
- - - - - - - - - - - - - - - - -
Original Submitted: {$ticket_timestamp}Last Updated: {$ticket_lastupdate}Status: {if $ticket_status neq 3}Open{/if} {$ticket_statustext}
Category: {$ticket_category}Priority: {$ticket_prioritytext}Support Group: - - {if $ticket_forwardedGroupName eq "0"} - {$public_sgroup} - {else} - {$ticket_forwardedGroupName} - {/if} - -
Assigned To: {if $ticket_assignedTo neq ""} {$ticket_assignedToText} {else} {$not_assigned} {/if}
- - - - - {foreach from=$ticket_replies item=reply} - - - - {/foreach} - - {if $ticket_status eq 3} - - - - {/if} - - - - - - - - - - - -
-

- {$reply.timestamp} - {if $reply.permission eq '1'} - {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} - {else if $reply.permission gt '1'} - {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} - {/if} -

-

{if $reply.hidden eq 1}{/if}{$reply.replyContent}{if $reply.hidden eq 1}{/if}

-
-

Ticket is closed.

-
- - {if $ticket_status neq 3} - {$t_reply}: - - - {if isset($isMod) and $isMod eq "TRUE"} - - Hide reply for user. - {/if} - {/if} -
- {if isset($isMod) and $isMod eq "TRUE"} -
- - -
-
- - -
- {/if} -
- - - - -
- - - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket_info.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket_info.tpl deleted file mode 100644 index b8100c158..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket_info.tpl +++ /dev/null @@ -1,79 +0,0 @@ -{block name=content} -

[#{$ticket_id}] {$ticket_title}

- -

Actions

- - - {if isset($isMod) and $isMod eq "TRUE"}{/if} - - - -
Show Ticket LogSend Other TicketShow Ticket
- -

Additional Info

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ingame related
Shard ID: {$shard_id}
User_Id: {$user_id}
User Position: {$user_position}
View Position: {$view_position}
Client_Version: {$client_version}
Patch_Version: {$patch_version}
Server_Tick: {$server_tick}
Hardware & Software related
Memory: {$memory}
Processor: {$processor}
Cpu_Id: {$cpu_id}
Cpu_Mask: {$cpu_mask}
HT: {$ht}
OS: {$os}
NeL3D: {$nel3d}
Network related
Connect_State: {$connect_state}
Local_Address: {$local_address}
- -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket_log.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket_log.tpl deleted file mode 100644 index dfd44b11b..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_ticket_log.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{block name=content} - -

Log of Ticket #{$ticket_id}

- Title: {$ticket_title} - - - - - - - - - - {foreach from=$ticket_logs item=log} - - - - - - {/foreach} - - -
IDTimestampQuery
{$log.tLogId}{$log.timestamp}{$log.query}
- -{/block} - \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl deleted file mode 100644 index a7b5a95b1..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/show_user.tpl +++ /dev/null @@ -1,93 +0,0 @@ -{block name=content} - -

Profile of {$target_name}

- - - - - - - - - - - - - - -
Email:{$mail}
Role: - {if $userPermission eq 1}User{/if} - {if $userPermission eq 2}Moderator{/if} - {if $userPermission eq 3}Admin{/if} -
- - - -

Actions

- - - - - {if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1} - {if $userPermission eq 1} - - - {else if $userPermission eq 2 } - - - {else if $userPermission eq 3 } - - - {/if} - - {/if} - -
- Edit User - - Send Ticket - - Make Moderator - - Make Admin - - Demote to User - - Make Admin - - Demote to User - - Demote to Moderator -
- - - -

Tickets of {$target_name}

- - - - - - - - - - - - {foreach from=$ticketlist item=ticket} - - - - - - - - - {/foreach} - - -
IDTitleTimestampCategoryStatus
{$ticket.tId}{$ticket.title}{$ticket.timestamp}{$ticket.category}{$ticket.statusText}
- - -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl deleted file mode 100644 index b6eab4abb..000000000 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/userlist.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{block name=content} - - - - - - - - - - - - - {foreach from=$userlist item=element} - - - - - {if $element.permission eq 1}{/if} - {if $element.permission eq 2}{/if} - {if $element.permission eq 3}{/if} - - - {/foreach} - - -
IdUsernameEmailPermissionAction
{$element.id}{$element.username}{$element.email}UserModeratorAdmin - - - - {if isset($isAdmin) and $isAdmin eq 'TRUE' and $element.id neq 1} - - {if $element.permission eq 1} - - - {else if $element.permission eq 2 } - - - {else if $element.permission eq 3 } - - - {/if} - {/if} - -
- Show User - - Edit User - Make ModeratorMake AdminDemote to UserMake AdminDemote to UserDemote to Moderator
-
-
- - « | - {foreach from=$links item=link} - {if $link == $currentPage}{/if}{$link}{if $link == $currentPage}{/if} | - {/foreach} - » - -
- -{/block} - diff --git a/code/ryzom/tools/server/ryzom_ams/todo.txt b/code/ryzom/tools/server/ryzom_ams/todo.txt deleted file mode 100644 index 0611c9503..000000000 --- a/code/ryzom/tools/server/ryzom_ams/todo.txt +++ /dev/null @@ -1,10 +0,0 @@ --Make Permission www dependend, so it can be implemented in drupal with hook_permission(); --in helpers make_folders mkdir($value); should be drupal_mkdir(); --fix the callback in add_user_to_sgroup.php and show_sgroup.php in the func dir --put mycrypt stuff from func/modify_email_of_sgroup in the setPassword itself. --fix the error paths by making them use the ingame_path & outgame paths too - -module related: --put the install.php stuff into the module.install file --add extra data fields that can be changed like the gender, country - diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php deleted file mode 100644 index 7ade3efb6..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ /dev/null @@ -1,118 +0,0 @@ - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Thu Aug 22 20:07:54 2002 (receveur) .basics.name = long_axe +Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.category = Heavy +Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.latency = 6 +Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.rate of fire = 2 +Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.skill = GreatAxe +Thu Aug 22 20:08:46 2002 (receveur) .melee weapon.damage type = Slashing +Thu Aug 22 20:09:22 2002 (receveur) .basics.quality level = $filename +Tue Aug 27 14:56:14 2002 (wuibout) .3d.icon = MW_2h_axe.tga +Thu Oct 03 15:20:39 2002 (receveur) .basics.weight = very heavy +Thu Oct 03 15:20:48 2002 (receveur) .basics.hit points = high +Thu Dec 12 11:51:26 2002 (favre) formName Pasted = +Fri Jan 03 15:56:12 2003 (receveur) .melee weapon.skill = great axe +Thu Feb 20 18:09:11 2003 (favre) .faber.Career = faber +Thu Feb 20 18:09:11 2003 (favre) .faber.Skill = make two_hands melee weapons +Thu Feb 20 18:09:11 2003 (favre) .faber.Specialization = make long axe +Wed Feb 26 17:36:47 2003 (favre) .faber.Tool type = Sharpener +Wed Feb 26 17:36:52 2003 (favre) .crafting tool.type = Sharpener +Thu Feb 27 17:21:36 2003 (receveur) .faber.Create.MP 1 = yellow_amber.item +Thu Feb 27 17:21:36 2003 (receveur) .faber.Create.Quantity 1 = 6 +Thu Feb 27 17:21:39 2003 (receveur) .faber.Create.Quantity 2 = 5 +Thu Feb 27 17:22:12 2003 (receveur) .faber.Create.MP 2 = desert_pod.items +Mon Mar 03 15:29:25 2003 (receveur) .melee weapon.latency = 4 +Mon Mar 03 15:29:25 2003 (receveur) .melee weapon.rate of fire = +Thu May 29 16:05:58 2003 (fleury) .melee weapon.latency = 6 +Tue Sep 16 19:24:56 2003 (coutelas) .basics.ItemType = Two Hand Axe +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 1 = Raw Material for Blade +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 2 = Raw Material for Shaft +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 2 Property = Stiff +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 3 = Raw Material for Grip +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 3 Property = Grip +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 4 = Raw Material for Counterweight +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 4 Property = Dense +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 1 = 1 +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 2 = 1 +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 3 = 1 +Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 4 = 1 +Tue Sep 16 19:24:56 2003 (coutelas) .melee weapon.skill = two handed axe +Tue Sep 16 19:25:31 2003 (coutelas) .AsBrick.Client.Icon = MW_2h_axe.tga +Thu Sep 18 12:25:52 2003 (coutelas) .basics.family = melee weapon +Thu Sep 18 18:57:52 2003 (coutelas) .AsBrick.Basics.FamilyId = RootFaber +Fri Sep 19 11:39:52 2003 (coutelas) .AsBrick.Client.IconOver = item_plan_over.tga + diff --git a/code/ryzom/tools/server/sabrina_test/_fy_Wea_Hache2M.sitem b/code/ryzom/tools/server/sabrina_test/_fy_Wea_Hache2M.sitem new file mode 100644 index 000000000..cd2da7cff --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/_fy_Wea_Hache2M.sitem @@ -0,0 +1,42 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + Fri Jul 05 10:15:18 2002 (mauduit) .3d.shape = TR_HOM_VISAGE.shape +Fri Jul 05 10:25:30 2002 (mauduit) .3d.shape = Tr_Wea_Hache2M.shape +Thu Jul 11 11:34:49 2002 (mauduit) .3d.anim_set = 2H +Thu Jul 11 11:34:49 2002 (mauduit) .3d.shape_female = Tr_Wea_Hache2M.shape +Thu Jul 11 11:34:49 2002 (mauduit) .basics.EquipmentInfo.EquipmentSlots[0] = Right Hand +Thu Jul 11 11:34:49 2002 (mauduit) .basics.family = melee weapon +Thu Jul 11 11:34:49 2002 (mauduit) .basics.origin = tryker +Thu Jul 11 11:34:49 2002 (mauduit) formName Resized = 1 +Thu Jul 11 13:33:18 2002 (mauduit) .3d.shape = FY_Wea_hache2M.shape +Thu Jul 11 13:33:18 2002 (mauduit) .3d.shape_female = FY_Wea_hache2M.shape +Thu Jul 11 13:33:18 2002 (mauduit) .basics.origin = fyros +Tue Aug 27 15:02:55 2002 (wuibout) .3d.icon background = BK_fyros.tga + diff --git a/code/ryzom/tools/server/sabrina_test/bcca01.sbrick b/code/ryzom/tools/server/sabrina_test/bcca01.sbrick new file mode 100644 index 000000000..80dac9c12 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bcca01.sbrick @@ -0,0 +1,15 @@ + +
+ + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bcfmea01.sbrick b/code/ryzom/tools/server/sabrina_test/bcfmea01.sbrick new file mode 100644 index 000000000..1ce1fa5f3 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bcfmea01.sbrick @@ -0,0 +1,59 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bcpa01.sbrick b/code/ryzom/tools/server/sabrina_test/bcpa01.sbrick new file mode 100644 index 000000000..f403ba2a9 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bcpa01.sbrick @@ -0,0 +1,27 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bmca01.sbrick b/code/ryzom/tools/server/sabrina_test/bmca01.sbrick new file mode 100644 index 000000000..19ce77280 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bmca01.sbrick @@ -0,0 +1,23 @@ + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bmpa01.sbrick b/code/ryzom/tools/server/sabrina_test/bmpa01.sbrick new file mode 100644 index 000000000..69ec2198f --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bmpa01.sbrick @@ -0,0 +1,36 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bmtodea01.sbrick b/code/ryzom/tools/server/sabrina_test/bmtodea01.sbrick new file mode 100644 index 000000000..bbd0227bc --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bmtodea01.sbrick @@ -0,0 +1,23 @@ + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bmtodmb01.sbrick b/code/ryzom/tools/server/sabrina_test/bmtodmb01.sbrick new file mode 100644 index 000000000..7c6f743b7 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bmtodmb01.sbrick @@ -0,0 +1,24 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/sabrina_test/bot_manager.h b/code/ryzom/tools/server/sabrina_test/bot_manager.h new file mode 100644 index 000000000..b74c9904b --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/bot_manager.h @@ -0,0 +1,191 @@ +/* + + Sabrina_test project: player manager + +*/ + +#include "nel/misc/sstring.h" +#include "sabrina/entity_base.h" +#include "sabrina/sabrina_actor_creature.h" + +#ifdef NL_OS_WINDOWS +#pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list +#endif + +//------------------------------------------------------------------------ +// CNPCRecord / CCreatureRecord +//------------------------------------------------------------------------ + +class CNPCRecord: public CEntityBase +{ +public: + CNPCRecord(const CSString& name); + + ISabrinaActor* getSabrinaActor() { return const_cast(getSabAct()); } + + const CSString& getName() const { return _Name; } + const CSabrinaActorCreature* getSabAct() const { return &_SabrinaActor; } + +private: + CSString _Name; + CSabrinaActorCreature _SabrinaActor; +}; + +class CCreatureRecord: public CEntityBase +{ +public: + CCreatureRecord(const CSString& name); + + ISabrinaActor* getSabrinaActor() { return const_cast(getSabAct()); } + + const CSString& getName() const { return _Name; } + const CSabrinaActorCreature* getSabAct() const { return &_SabrinaActor; } + +private: + CSString _Name; + CSabrinaActorCreature _SabrinaActor; +}; + +//------------------------------------------------------------------------ +// CNPCRecord / CCreatureRecord inlines +//------------------------------------------------------------------------ + +CNPCRecord::CNPCRecord(const CSString& name): _SabrinaActor(this) +{ + _Name=name; +} + +CCreatureRecord::CCreatureRecord(const CSString& name): _SabrinaActor(this) +{ + _Name=name; +} + +//------------------------------------------------------------------------ +// CBotManager +//------------------------------------------------------------------------ + +class CBotManager +{ +public: + void addNPC(const CSString& name); + void removeNPC(const CSString& name); + void listNPCs() const; + CNPCRecord* getNPC(const CSString& name); + + void addCreature(const CSString& name,const NLMISC::CSheetId sheet); + void removeCreature(const CSString& name); + void listCreatures() const; + CCreatureRecord* getCreature(const CSString& name); + + CEntityBase* getBot(const CSString& name); + +private: + std::vector _NPCs; + std::vector _Creatures; +}; + +//------------------------------------------------------------------------ +// CBotManager inlines - Creature +//------------------------------------------------------------------------ + +inline void CBotManager::addCreature(const CSString& name,const NLMISC::CSheetId sheet) +{ + removeCreature(name); + _Creatures.push_back(new CCreatureRecord(name)); +} + +inline void CBotManager::removeCreature(const CSString& name) +{ + for (uint i=_Creatures.size();i--;) + { + if (_Creatures[i]->getName()==name) + { + delete _Creatures[i]; + _Creatures[i]=_Creatures[_Creatures.size()-1]; + _Creatures.pop_back(); + } + } +} + +inline void CBotManager::listCreatures() const +{ + for (uint i=_Creatures.size();i--;) + { + CSString s="Creature"; + s+=": "+_Creatures[i]->getName(); + s+=": "+_Creatures[i]->getSabAct()->stateString(); + nlinfo("%s",s.c_str()); + } +} + +inline CCreatureRecord* CBotManager::getCreature(const CSString& name) +{ + for (uint i=_Creatures.size();i--;) + { + if (_Creatures[i]->getName()==name) + { + return _Creatures[i]; + } + } + return NULL; +} + +//------------------------------------------------------------------------ +// CBotManager inlines - NPC +//------------------------------------------------------------------------ + +inline void CBotManager::addNPC(const CSString& name) +{ + removeNPC(name); + _NPCs.push_back(new CNPCRecord(name)); +} + +inline void CBotManager::removeNPC(const CSString& name) +{ + for (uint i=_NPCs.size();i--;) + { + if (_NPCs[i]->getName()==name) + { + delete _NPCs[i]; + _NPCs[i]=_NPCs[_NPCs.size()-1]; + _NPCs.pop_back(); + } + } +} + +inline void CBotManager::listNPCs() const +{ + for (uint i=_NPCs.size();i--;) + { + CSString s="NPC"; + s+=": "+_NPCs[i]->getName(); + s+=": "+_NPCs[i]->getSabAct()->stateString(); + nlinfo("%s",s.c_str()); + } +} + +inline CNPCRecord* CBotManager::getNPC(const CSString& name) +{ + for (uint i=_NPCs.size();i--;) + { + if (_NPCs[i]->getName()==name) + { + return _NPCs[i]; + } + } + return NULL; +} + +//------------------------------------------------------------------------ +// CBotManager inlines +//------------------------------------------------------------------------ + +inline CEntityBase* CBotManager::getBot(const CSString& name) +{ + CEntityBase* result= getNPC(name); + if (result!=NULL) + return result; + else + return getCreature(name); +} + diff --git a/code/ryzom/tools/server/sabrina_test/craft1.sphrase b/code/ryzom/tools/server/sabrina_test/craft1.sphrase new file mode 100644 index 000000000..64b86dad0 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/craft1.sphrase @@ -0,0 +1,15 @@ + +
+ + + + + + + + + + Sun Oct 12 01:01:33 2003 (miller) .brick 0 = bcpa01.sbrick +Sun Oct 12 01:01:33 2003 (miller) .brick 1 = bsfmea01.sbrick +Sun Oct 12 01:01:33 2003 (miller) .brick 2 = bcca01.sbrick + diff --git a/code/ryzom/tools/server/sabrina_test/icfm2sa.sitem b/code/ryzom/tools/server/sabrina_test/icfm2sa.sitem new file mode 100644 index 000000000..51201aa22 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/icfm2sa.sitem @@ -0,0 +1,40 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Thu Aug 08 09:25:01 2002 (mauduit) .3d.map_variant = Low Quality +Fri Sep 27 15:31:17 2002 (favre) .basics.name = fyros long axe +Thu Sep 18 12:28:08 2003 (coutelas) .basics.origin = fyros +Thu Sep 18 12:28:08 2003 (coutelas) .faber.Create.MP 1 Family = Wood +Thu Sep 18 12:28:08 2003 (coutelas) .faber.Skill = burning 2h axe craft +Thu Sep 18 12:28:08 2003 (coutelas) .melee weapon.skill = two handed axe fyros +Fri Sep 19 12:05:35 2003 (coutelas) .AsBrick.Client.IconBack = BK_fyros_brick.tga + diff --git a/code/ryzom/tools/server/sabrina_test/magic1.sphrase b/code/ryzom/tools/server/sabrina_test/magic1.sphrase new file mode 100644 index 000000000..cc8aef75d --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/magic1.sphrase @@ -0,0 +1,17 @@ + +
+ + + + + + + + + + + Sun Oct 12 00:57:33 2003 (miller) .brick 0 = bmpa01.sbrick +Sun Oct 12 00:57:33 2003 (miller) .brick 1 = bmtodea01.sbrick +Sun Oct 12 00:57:33 2003 (miller) .brick 2 = bmtodmb01.sbrick +Sun Oct 12 00:57:33 2003 (miller) .brick 3 = bmca01.sbrick + diff --git a/code/ryzom/tools/server/sabrina_test/player_manager.h b/code/ryzom/tools/server/sabrina_test/player_manager.h new file mode 100644 index 000000000..6ab88fd7f --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/player_manager.h @@ -0,0 +1,114 @@ +/* + + Sabrina_test project: player manager + +*/ + +#include "nel/misc/sstring.h" +#include "sabrina/entity_base.h" +#include "sabrina/sabrina_actor_player.h" + +#ifdef NL_OS_WINDOWS +#pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list +#endif + +//------------------------------------------------------------------------ +// CPlayerRecord +//------------------------------------------------------------------------ + +class CPlayerRecord: public CEntityBase +{ +public: + CPlayerRecord(const CSString& name); + + ISabrinaActor* getSabrinaActor() { return const_cast(getSabAct()); } + + const CSString& getName() const { return _Name; } + const CSabrinaActorPlayer* getSabAct() const { return &_SabrinaActor; } + CSabrinaActorPlayer* getSabAct() { return &_SabrinaActor; } + +private: + CSString _Name; + CSabrinaActorPlayer _SabrinaActor; +}; + +//------------------------------------------------------------------------ +// CPlayerRecord inlines +//------------------------------------------------------------------------ + +CPlayerRecord::CPlayerRecord(const CSString& name): _SabrinaActor(this) +{ + _Name=name; +} + +//------------------------------------------------------------------------ +// CPlayerManager +//------------------------------------------------------------------------ + +class CPlayerManager +{ +public: + CPlayerManager(); + + void addPlayer(const CSString& name); + void removePlayer(const CSString& name); + void listPlayers() const; + CPlayerRecord* getPlayer(const CSString& name); + +private: + std::vector _Players; + uint32 _UniquePlayerId; +}; + +//------------------------------------------------------------------------ +// CPlayerManager inlines +//------------------------------------------------------------------------ + +CPlayerManager::CPlayerManager() +{ + _UniquePlayerId=0; +} + +inline void CPlayerManager::addPlayer(const CSString& name) +{ + removePlayer(name); + _Players.push_back(new CPlayerRecord(name)); + _Players[_Players.size()-1]->setEntityRowId(_UniquePlayerId++); + _Players[_Players.size()-1]->getSabAct()->addMemoryBank("default"); +} + +inline void CPlayerManager::removePlayer(const CSString& name) +{ + for (uint i=_Players.size();i--;) + { + if (_Players[i]->getName()==name) + { + delete _Players[i]; + _Players[i]=_Players[_Players.size()-1]; + _Players.pop_back(); + } + } +} + +inline void CPlayerManager::listPlayers() const +{ + for (uint i=_Players.size();i--;) + { + CSString s="Player"; + s+=": "+_Players[i]->getName(); + s+=": "+_Players[i]->getSabAct()->stateString(); + nlinfo("%s",s.c_str()); + } +} + +inline CPlayerRecord* CPlayerManager::getPlayer(const CSString& name) +{ + for (uint i=_Players.size();i--;) + { + if (_Players[i]->getName()==name) + { + return _Players[i]; + } + } + return NULL; +} diff --git a/code/ryzom/tools/server/sabrina_test/sabrina_test.cpp b/code/ryzom/tools/server/sabrina_test/sabrina_test.cpp new file mode 100644 index 000000000..bfa6bc61d --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/sabrina_test.cpp @@ -0,0 +1,313 @@ +/** \file sabrina_test.cpp + * + * $Id: sabrina_test.cpp,v 1.2 2004/03/01 19:22:19 lecroart Exp $ + */ + + + +#include "nel/misc/command.h" +#include "nel/misc/path.h" + +#include "game_share/ryzom_entity_id.h" +#include "game_share/tick_event_handler.h" + +#include "sabrina_test.h" +#include "sabrina/sabrina_pointers.h" +#include "sabrina/sabrina_phrase_description.h" +#include "sabrina/sabrina_phrase_manager.h" + + +using namespace NLMISC; +using namespace NLNET; +using namespace std; + +//--------------------------------------------------- +// CallbackArray +//--------------------------------------------------- +TUnifiedCallbackItem CallbackArray[] = +{ + { "AZERTY", NULL }, +}; + +//--------------------------------------------------- +// Globals +//--------------------------------------------------- +namespace SABTEST +{ + CServiceTest* TheService; + uint32 SimTickCount; +} + + +//--------------------------------------------------- +// Service Init : +// +//--------------------------------------------------- +void CServiceTest::init () +{ + SABTEST::TheService=this; + setUpdateTimeout(100); + + CTickEventHandler::init(SABTEST::TheService->tickUpdate); + + CSabrinaStaticPhraseDescriptionManager::init(); + CSabrinaPhraseManager::init(); +} + +//--------------------------------------------------- +// Service update : +// +//--------------------------------------------------- +bool CServiceTest::update () +{ + if (SABTEST::SimTickCount) + { + CTickEventHandler::simulateTick(); + --SABTEST::SimTickCount; + } + return true; +} + +//--------------------------------------------------- +// Tick update : +// +//--------------------------------------------------- +void CServiceTest::tickUpdate () +{ + CSabrinaPhraseManager::update(); +} + +//--------------------------------------------------- +// Service release : +// +//--------------------------------------------------- +void CServiceTest::release () +{ + CSabrinaStaticPhraseDescriptionManager::release(); + CSabrinaPhraseManager::release(); +} + +/****************************************************************\ + Service register +\****************************************************************/ +NLNET_SERVICE_MAIN (CServiceTest, "SabrinaTest", "sabrina_test", 0, CallbackArray, "", "") + + +/****************************************************************\ + Command section +\****************************************************************/ + +ISabrinaActor* getActorByName(const CSString& name) +{ + CEntityBase* result=NULL; + + result= SABTEST::plrMgr()->getPlayer(name); + if (result!=NULL) + return result->getSabrinaActor(); + + result= SABTEST::botMgr()->getBot(name); + if (result!=NULL) + return result->getSabrinaActor(); + + return NULL; +} + +NLMISC_COMMAND(newPlayer,"createPlayer","") +{ + if(args.size() != 1) return false; + if (getActorByName(args[0])!=NULL) + { + nlinfo("Actor already exists: %s",args[0].c_str()); + return true; + } + SABTEST::plrMgr()->addPlayer(args[0]); + return true; +} + +NLMISC_COMMAND(newNPC,"createNPC","") +{ + if(args.size() != 1) return false; + if (getActorByName(args[0])!=NULL) + { + nlinfo("Actor already exists: %s",args[0].c_str()); + return true; + } + SABTEST::botMgr()->addNPC(args[0]); + return true; +} + +NLMISC_COMMAND(newCreature,"createCreature"," ") +{ + if(args.size() != 2) return false; + if (getActorByName(args[0])!=NULL) + { + nlinfo("Actor already exists: %s",args[0].c_str()); + return true; + } + SABTEST::botMgr()->addCreature(args[0],NLMISC::CSheetId(args[1])); + return true; +} + + +NLMISC_COMMAND(plrTarget,"plrTarget"," ") +{ + if(args.size() != 2) return false; + + ISabrinaActor* actor= getActorByName(args[0]); + ISabrinaActor* target= getActorByName(args[1]); + + if (actor==NULL) + { + nlinfo("Failed to identify actor: %s",args[0].c_str()); + return true; + } + if (target==NULL) + { + nlinfo("Failed to identify target: %s",args[1].c_str()); + return true; + } + + actor->getEntity()->setTarget(target->getEntity()); + + return true; +} + + +NLMISC_COMMAND(plrMemSPhrase,"plrMemSPhrase"," ") +{ + if(args.size() != 4) return false; + + // get a pointer to the player. + CSabrinaActorPlayer* actor= const_cast(SABTEST::plrMgr()->getPlayer(args[0])->getSabAct()); + if (actor==NULL) + { + nlinfo("Failed to identify player: %s",args[0].c_str()); + return true; + } + + // convert 'slot' param to int + uint32 slot; + if ( CSString(args[2]).atoi(slot)==false ) + { + nlwarning("Invalid slot..."); + return false; + } + + // lookup the phrase in the static phrase table + ISabrinaPhraseDescriptionPtr phrase= CSabrinaStaticPhraseDescriptionManager::getPhrase(NLMISC::CSheetId(args[3])); + if (phrase==NULL) + { + nlwarning("Phrase file not found..."); + return false; + } + + // do the memorising + actor->memorize(args[1],slot,phrase); + return true; +} + +NLMISC_COMMAND(plrMemUserPhrase,"plrMemSPhrase"," [[...]]") +{ + if(args.size() < 5) return false; + + // get a pointer to the player. + CSabrinaActorPlayer* actor= const_cast(SABTEST::plrMgr()->getPlayer(args[0])->getSabAct()); + if (actor==NULL) + { + nlinfo("Failed to identify player: %s",args[0].c_str()); + return true; + } + + // convert 'slot' params to int + uint32 slot; + if ( CSString(args[2]).atoi(slot)==false ) + return false; + + // setup a vector of bricks + std::vector bricks; + for (uint32 i=4;imemorize(args[1],slot,newPhrase); + return true; +} + +NLMISC_COMMAND(plrUsePhrase, "plrUsePhrase ", " ") +{ + if(args.size() != 3) return false; + + // get a pointer to the player. + CSabrinaActorPlayer* actor= const_cast(SABTEST::plrMgr()->getPlayer(args[0])->getSabAct()); + if (actor==NULL) + { + nlinfo("Failed to identify player: %s",args[0].c_str()); + return true; + } + + // convert 'slot' params to string + uint32 slot; + if ( CSString(args[2]).atoi(slot)==false ) + return false; + + // do the memorising + actor->setActiveMemoryBank(args[1]); + actor->executeAction(slot); + return true; +} + + +NLMISC_COMMAND(listActors,"listEntities","") +{ + if(args.size() != 0) return false; + SABTEST::botMgr()->listCreatures(); + SABTEST::botMgr()->listNPCs(); + SABTEST::plrMgr()->listPlayers(); + return true; +} + +NLMISC_COMMAND(simTick,"simulate 1 or more tick","[]") +{ + uint32 count=1; + if (args.size()>0) + count=atoi(args[0].c_str()); + if (count==0) + return false; + + SABTEST::SimTickCount=count; + return true; +} + +NLMISC_COMMAND(makeSheetId,"make sheet id file from scratch","") +{ + if(args.size() != 0) return false; + + std::string fileName="src_v2/sabrina_test/sheet_id.bin.test"; + nlinfo("Creating file: %s",fileName.c_str()); + + std::map allFiles; + + std::vector itemFiles; + std::vector brickFiles; + std::vector phraseFiles; + + NLMISC::CPath::getFileList("sitem",itemFiles); + NLMISC::CPath::getFileList("sbrick",brickFiles); + NLMISC::CPath::getFileList("sphrase",phraseFiles); + + nlinfo("adding %d sitem files",itemFiles.size()); + nlinfo("adding %d sbrick files",brickFiles.size()); + nlinfo("adding %d sphrase files",phraseFiles.size()); + + uint32 i; + for (i=itemFiles.size();i--;) allFiles[NLMISC::CSheetId().build(i+1,1)]= itemFiles[i]; + for (i=brickFiles.size();i--;) allFiles[NLMISC::CSheetId().build(i+1,2)]= brickFiles[i]; + for (i=phraseFiles.size();i--;) allFiles[NLMISC::CSheetId().build(i+1,3)]= phraseFiles[i]; + + NLMISC::COFile file(fileName); + file.serialCont(allFiles); + file.close(); + + return true; +} diff --git a/code/ryzom/tools/server/sabrina_test/sabrina_test.h b/code/ryzom/tools/server/sabrina_test/sabrina_test.h new file mode 100644 index 000000000..d361b3da5 --- /dev/null +++ b/code/ryzom/tools/server/sabrina_test/sabrina_test.h @@ -0,0 +1,68 @@ +/** \file sabrina_test.h + * + * $Id: sabrina_test.h,v 1.2 2004/03/01 19:22:19 lecroart Exp $ + */ + + + + +#ifndef GD_SABRINA_TEST_H +#define GD_SABRINA_TEST_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/time_nl.h" +#include "nel/net/service.h" +#include "player_manager.h" +#include "bot_manager.h" + +//------------------------------------------------------------------------ +// Class for the srevice objects... + +class CServiceTest : public NLNET::IService +{ +public: + // Service basics... + void init (); + bool update (); + void release (); + + static void tickUpdate(); + + // accessors for entoty managers + CBotManager* getBotManager() + { + return &_BotManager; + } + + CPlayerManager* getPlrManager() + { + return &_PlayerManager; + } + +private: + CBotManager _BotManager; + CPlayerManager _PlayerManager; +}; + +//------------------------------------------------------------------------ +// Globals and Handy routines for accessing the service object + +namespace SABTEST +{ + extern CServiceTest* TheService; + + inline CPlayerManager* plrMgr() + { + return TheService->getPlrManager(); + } + + inline CBotManager* botMgr() + { + return TheService->getBotManager(); + } +} + +#endif // GD_SERVICE_TEST_H + + +/* End of sabrina_test.h */ diff --git a/code/ryzom/tools/server/sabrina_test/sheet_id.bin b/code/ryzom/tools/server/sabrina_test/sheet_id.bin new file mode 100644 index 000000000..5717a718f Binary files /dev/null and b/code/ryzom/tools/server/sabrina_test/sheet_id.bin differ diff --git a/code/ryzom/tools/server/service_test/front_end_property_receiver.cpp b/code/ryzom/tools/server/service_test/front_end_property_receiver.cpp new file mode 100644 index 000000000..a47b1a192 --- /dev/null +++ b/code/ryzom/tools/server/service_test/front_end_property_receiver.cpp @@ -0,0 +1,982 @@ +/** \file front_end_property_receiver.cpp + * Container for manage property receivers for front end + * + * $Id: front_end_property_receiver.cpp,v 1.21 2004/03/01 19:22:19 lecroart Exp $ + */ + + + +#include "front_end_property_receiver.h" + +#include "nel/misc/path.h" + +using namespace std; +using namespace NLNET; +using namespace NLMISC; +using namespace NLGEORGES; + +// Static members of CFrontEndPropertyReceiver +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::_FirstFreeEntity; +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::_FirstUpdatedEntityProperties; +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::_FirstUpdatedEntityVision; +vector< CFrontEndPropertyReceiver::SEntity > CFrontEndPropertyReceiver::_VectorEntities; +CFrontEndPropertyReceiver::TMapIdToIndex CFrontEndPropertyReceiver::_MapIdToIndex; +//CFrontEndPropertyReceiver::SIndexProperties CFrontEndPropertyReceiver::PropertyIndexByType [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ]; +CFrontEndPropertyReceiver::SPropertyDesc CFrontEndPropertyReceiver::PropertiesProperty [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ]; +CFrontEndPropertyReceiver::SOtherPropertyDesc CFrontEndPropertyReceiver::OtherProperties [ NB_OTHER_PROPERTIES ]; +uint32 CFrontEndPropertyReceiver::PropertiesContinuousMask [ NB_TYPE_ENTITIES ]; + + +//--------------------------------------------------- +// Init +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::initFrontEndPropertyReceiver( const string& filenameProperties, const string& filenameEntityIndex ) +{ + // reserve place for vector.... + _VectorEntities.resize( FE_NBMAX_ENTITIES ); // not reserve! + + // prepare FreeEntityProperties linking; + unsigned int i = 0; + for( std::vector< SEntity >::iterator it = _VectorEntities.begin(); it != _VectorEntities.end(); ++it ) + { + it->code = 0; + it->bitfield = 0; + it->mask = 0; + it->nextFreeEntity = ++i; + it->nextUpdatedEntityProperties = -2; + it->nextUpdatedEntityVision = -2; + } +/* + for( i = 0; i < NB_TYPE_ENTITIES; ++i ) + { + for( int j = 0; j < NB_PROPERTIES_PER_ENTITY; ++j ) + { + PropertyIndexByType [ i ] [ j ].PropertyName = ""; + PropertyIndexByType [ i ] [ j ].PropertyIndex = 127; + } + } +*/ + // prepare FreeEntityProperties linking; + _FirstFreeEntity = 0; + // prepare UpdatedEntityProperties linking; + _FirstUpdatedEntityProperties = -1; + // prepare UpdatedEntityProperties linking; + _FirstUpdatedEntityVision = -1; + + // Load sheet for properties's property + CLoader loader; + UFormElm item; + + item.SetLoader( &loader ); + + try + { + item.Load( CPath::lookup( filenameEntityIndex ) ); + } + catch (Exception &e){ nlwarning("CFrontEndPropertyReceiver::initFrontEndPropertyReceiver : '%s' -> '%s'.", filenameEntityIndex.c_str(), e.what());} + + map< string, uint8 > EntityIndexMap; + + UFormElm *pRoot = item.GetElt(0); + initEntityIndex( pRoot, EntityIndexMap ); + + item.Clear(); + + try + { + item.Load( CPath::lookup( filenameProperties ) ); + } + catch (Exception &e){ nlwarning("CFrontEndPropertyReceiver::initFrontEndPropertyReceiver : '%s' -> '%s'.", filenameProperties.c_str(), e.what());} + + pRoot = item.GetElt(0); + initPropertyDescriptor( pRoot, EntityIndexMap ); + + // Precalculate the the continuous mask + for( int ii = 0; ii < NB_TYPE_ENTITIES; ++ii ) + { + uint32 continuousMask = 0; + + for( uint32 j = 0; j < NB_PROPERTIES_PER_ENTITY; ++j ) + { + for( int k = 0; k < NB_PROPERTIES_PER_ENTITY; ++k ) + { + if( PropertiesProperty [ ii ] [ k ].Index == j ) + { + uint32 idx = 1; + idx <<= PropertiesProperty [ ii ] [ k ].Index; + continuousMask |= idx & ( ( PropertiesProperty [ ii ] [ k ].Continuous) ? 0 : 1 ); + } + } + } + // Changed 4/04/2002: i to ii + PropertiesContinuousMask [ ii ] = continuousMask; + } + + // register callback function for process delta update messages of mirror and vision + NLNET::TUnifiedCallbackItem _cbArray[3]; + + _cbArray[0].Callback = cbDeltaUpdate; + _cbArray[0].Key = "DELTA_UPDATE"; + _cbArray[1].Callback = cbDeltaUpdateRemove; + _cbArray[1].Key = "DELTA_UPDATE_REMOVE"; + _cbArray[2].Callback = cbDeltaVision; + _cbArray[2].Key = "VISIONS_DELTA"; + + CUnifiedNetwork::getInstance()->addCallbackArray( _cbArray, 3 ); +} + +//--------------------------------------------------- +// Init entity index map with sheet +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::initEntityIndex( UFormElm *pElt, map< string, uint8 >& EntityIndexMap ) +{ + uint32 i; + + CItemEltAtom *pAtomElt = dynamic_cast(pElt); + if (pAtomElt != NULL) + { + EntityIndexMap.insert( make_pair( pAtomElt->GetName(), (uint8) atoi( pAtomElt->GetCurrentResult().c_str() ) ) ); + return; + } + + // If the element is a structure + CItemEltStruct *pStructElt = dynamic_cast(pElt); + if (pStructElt != NULL) + { + for (i = 0; i < pStructElt->GetNbStructElt(); ++i) + initEntityIndex(pStructElt->GetStructElt(i), EntityIndexMap ); + return; + } +} + +//--------------------------------------------------- +// Init properties descriptor +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::initPropertyDescriptor( UFormElm *pElt, map< string, uint8 >& EntityIndexMap, uint32 ident, uint32 itemNumber, bool OtherProperty ) +{ + uint32 i; + static uint32 entityIndex; + + CItemEltAtom *pAtomElt = dynamic_cast(pElt); + if (pAtomElt != NULL) + { + nldebug("FEPROPINIT: Atom element %s, value %s", pAtomElt->GetName().c_str(), pAtomElt->GetCurrentResult().c_str() ); + + if( ident == 2 ) + { + entityIndex = atoi( pAtomElt->GetCurrentResult().c_str() ); + } + else + { + if( !OtherProperty ) + { + initPropertyDesc( pAtomElt, entityIndex, itemNumber ); + } + } + return; + } + + // If the element is a structure + CItemEltStruct *pStructElt = dynamic_cast(pElt); + if (pStructElt != NULL) + { + if( ident == 0 ) + { + nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() ); + } + else if( ident == 1 ) + { + nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() ); + } + else if( ident == 2 ) + { + nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() ); + } + else if( ident == 3 ) + { + nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() ); + } + else if( ident == 4 ) + { + nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() ); + } + if( ident == 3 ) + { + UFormElm *pEltChild = pStructElt->GetElt("Index"); + if( pEltChild != 0 ) + { + sint32 indexTest = atoi( pEltChild->GetCurrentResult().c_str() ); + if( atoi( pEltChild->GetCurrentResult().c_str() ) < 0) + { + OtherProperty = true; + initOtherPropertyDesc( pStructElt ); + } + else + { + OtherProperty = false; + } + } + } + for (i = 0; i < pStructElt->GetNbStructElt(); ++i) + { + initPropertyDescriptor( pStructElt->GetStructElt(i), EntityIndexMap/*, entityIndex*/, ident+1, itemNumber, OtherProperty ); + if( ident == 2 ) + { + itemNumber++; + }; + } + if( ident == 3 ) + { + if( PropertiesProperty [ entityIndex ] [ itemNumber ].Union == true ) + { + uint64 unionMask = 1; + + unionMask<<=PropertiesProperty [ entityIndex ] [ itemNumber ].NbBits; // setup bit NbBits to 1 (ie the one above desired bitmask) followed by all 0s + unionMask-=1; // setup the bitmask (bottm NbBits of unionMask are all 1 rest are 0) + unionMask<<=PropertiesProperty [ entityIndex ] [ itemNumber ].UnionShift; // shift up the bitmask to the correct location in the QuadWord + + PropertiesProperty [ entityIndex ] [ itemNumber ].UnionMask = unionMask; + } + } + return; + } +} + +//--------------------------------------------------- +// Init subscription for service +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::initFrontEndPropertySubscription( const string& serviceName ) +{ + nlinfo(" service name %s",serviceName.c_str() ); + + // subscribe to delta update for properties + pair< string, uint32 > Property; + + for( int ii = 0; ii < NB_TYPE_ENTITIES; ++ii ) + { + for( uint32 j = 0; j < NB_PROPERTIES_PER_ENTITY; ++j ) + { + if( PropertiesProperty [ii] [j].ServiceOwner == serviceName ) + { + Property = make_pair( PropertiesProperty [ii] [j].PropertyName, 1 << PropertiesProperty [ii] [j].UpdateFrequency ); + CFrontEndPropertyReceiver::askPropertySubscribe( serviceName, Property ); + } + } + } + + // subscribe to delta update for other properties (like Sheet Id ) + for( int i = 0; i < NB_OTHER_PROPERTIES; ++i ) + { + if( OtherProperties [i].ServiceOwner == serviceName ) + { + Property = make_pair( OtherProperties [i].PropertyName, 1 << OtherProperties [i].UpdateFrequency ); + CFrontEndPropertyReceiver::askPropertySubscribe( serviceName, Property ); + } + } +} + +//--------------------------------------------------- +// Remove entities in receiver when downing serviceID is owner +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::serviceDown( uint16 serviceId ) +{ + for( TMapIdToIndex::iterator it = _MapIdToIndex.begin(); it != _MapIdToIndex.end(); ++it ) + { + if( (*it).first.DynamicId == serviceId || (*it).first.CreatorId == serviceId ) + { + deleteEntity( (*it).first ); + } + } +} + +//--------------------------------------------------- +// release +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::freeFrontEndPropertyReceiver( void ) +{ + endUpdatedProperties(); + endUpdatedVision(); +} + +//--------------------------------------------------- +// Init property with george's sheet +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::initPropertyDesc( UFormElm *pElt, uint32 entity, uint32 property ) +{ + if( pElt->GetName() == string("Index") ) + { + PropertiesProperty [ entity ] [ property ].Index = (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else if( pElt->GetName() == string("NbBits") ) + { + PropertiesProperty [ entity ] [ property ].NbBits = (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else if(pElt->GetName() == string("Continuous") ) + { + PropertiesProperty [ entity ] [ property ].Continuous = (pElt->GetCurrentResult() == "true") ? true : false; + } + else if( pElt->GetName() == string("Union") ) + { + PropertiesProperty [ entity ] [ property ].Union = (pElt->GetCurrentResult() == "true") ? true : false; + } + else if( pElt->GetName() == string("Shift") ) + { + PropertiesProperty [ entity ] [ property ].UnionShift = (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else if( pElt->GetName() == string("PropertyName") ) + { + PropertiesProperty [ entity ] [ property ].PropertyName = pElt->GetCurrentResult(); + } + else if( pElt->GetName() == string("ServiceOwner") ) + { + PropertiesProperty [ entity ] [ property ].ServiceOwner = pElt->GetCurrentResult(); + } + else if( pElt->GetName() == string("UpdateFrequency") ) + { + PropertiesProperty [ entity ] [ property ].UpdateFrequency = (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else if( pElt->GetName() == string("PropertyType") ) + { + PropertiesProperty [ entity ] [ property ].PropertyType = (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else + { + nlwarning("CFrontEndPropertyReceiver::initPropertyDesc property %s is unknown for entity %d property %d", pElt->GetName().c_str(), entity, property ); + } +} + +//--------------------------------------------------- +// Init entity other properties with george's sheet +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::initOtherPropertyDesc( UFormElm *pEltProperty ) +{ + uint32 Index = 0; + + UFormElm *pElt = pEltProperty->GetElt("Index"); + if( pElt != 0 ) + { + Index = 255 - (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else + { + nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property Index not in properties's property sheet" ); + } + + pElt = pEltProperty->GetElt("NbBits"); + if( pElt != 0 ) + { + OtherProperties[ Index ].NbBits = (uint8) atoi( pElt->GetCurrentResult().c_str() ); + } + else + { + nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property NbBits not in properties's property sheet" ); + } + + pElt = pEltProperty->GetElt("PropertyName"); + if( pElt != 0 ) + { + OtherProperties[ Index ].PropertyName = pElt->GetCurrentResult(); + } + else + { + nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property PropertyName not in properties's property sheet" ); + } + + pElt = pEltProperty->GetElt("ServiceOwner"); + if( pElt != 0 ) + { + OtherProperties[ Index ].ServiceOwner = pElt->GetCurrentResult(); + } + else + { + nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property ServiceOwner not in properties's property sheet" ); + } +} + +//--------------------------------------------------- +// Entity management : delete entity +// +//--------------------------------------------------- +bool CFrontEndPropertyReceiver::deleteEntity( const CEntityId& id ) +{ + TPropertiesIndex i = findIndex( id ); + // if failed, do nothing + if( i == -1 ) + return( false ); + // must delete it! + _VectorEntities[i].code |= PROPERTY_CODE_ERASE; + + // If it's not in the list of updated entity, push it in! + if( _VectorEntities[i].nextUpdatedEntityProperties == -2 ) + { + _VectorEntities[i].nextUpdatedEntityProperties = _FirstUpdatedEntityProperties; + _FirstUpdatedEntityProperties = i; + } + return( true ); +} + +//--------------------------------------------------- +// Entity management : called for deleting entities +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::setDeleted( TPropertiesIndex indexprop ) +{ + // buid the link of free entries. + _VectorEntities[indexprop].nextFreeEntity = _FirstFreeEntity; + _FirstFreeEntity = indexprop; + releaseIndexToId( _VectorEntities[indexprop].id ); +} + +//--------------------------------------------------- +// Entity management : give pointer on SEntity +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::SEntity* CFrontEndPropertyReceiver::getEntity( const TPropertiesIndex indexprop ) +{ + return( &(_VectorEntities[indexprop]) ); +} + +//--------------------------------------------------- +// Property management : Set a new property +// +//--------------------------------------------------- +bool CFrontEndPropertyReceiver::setProperties( const CEntityId& id, uint32 index, TPropertiesValue& value ) +{ + // Find the index + TPropertiesIndex i = findIndex( id ); + if( i == -1 ) + { + // it's a new index to build + i = assignIndexToId( id ); + // if failed + if( i == -1 ) + return( false ); + // if not, it's a new entity + _VectorEntities[i].id = id; + _VectorEntities[i].code |= PROPERTY_CODE_NEW; + // Set the ContinueValuesMask; + TPropertiesContMask mask = 0; + // set mask of Continuous properties (bits for property continuous is set to 0, 1 if none continuous) + _VectorEntities[i].mask = PropertiesContinuousMask [ id.Type ]; + } + else + { + if( _VectorEntities[i].code & PROPERTY_CODE_ERASE ) + { + _VectorEntities[i].code &= ~PROPERTY_CODE_ERASE; + } + } + SEntity* p = &(_VectorEntities[i]); + + // Set the bitfield and the value + uint32 indexProperty = PropertiesProperty [ id.Type ] [ index ].Index; + if( (1 << indexProperty) & (~ p->mask) ) + { + p->bitfield |= 1 << indexProperty; + } + if( PropertiesProperty [ id.Type ] [ index ].Union ) + { + p->properties[ indexProperty ] = ( p->properties[ indexProperty ] & ~ PropertiesProperty [ id.Type ] [ index ].UnionMask ) | ( ( value << PropertiesProperty [ id.Type ] [ index ].UnionShift ) & PropertiesProperty [ id.Type ] [ index ].UnionMask ); + } + else + { + p->properties[ indexProperty ] = value; + } + // If it's not in the list of updated entity, push it in! + if( p->nextUpdatedEntityProperties == -2 ) + { + p->nextUpdatedEntityProperties = _FirstUpdatedEntityProperties; + _FirstUpdatedEntityProperties = i; + } + return( true ); +} + + +//--------------------------------------------------- +// Property management : Get the first modified properties since the last EndUpdatedProperties +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getFirstUpdatedProperties() +{ + return( _FirstUpdatedEntityProperties ); +} + +//--------------------------------------------------- +// Property management : Get the next modified properties +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getNextUpdatedProperties( TPropertiesIndex indexprop ) +{ + // if it's the end or continuous values have changed and there is not new ou erase entity in the code, then go to the next elt + SEntity* p = &(_VectorEntities[indexprop]); + TPropertiesIndex i = p->nextUpdatedEntityProperties; + if( ( i == -1 )||( p->code )||( p->bitfield & p->mask ) ) + return( i ); + else + return( getNextUpdatedProperties( i ) ); +} + +//--------------------------------------------------- +// Property management : Call it after getting all the updated properties (eg, the.GetNextUpdatedProperties function return -1 ) +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::endUpdatedProperties() +{ + // for all the entities in the list of updated + while( _FirstUpdatedEntityProperties != -1 ) + { + // Get the next entity + SEntity* p = &(_VectorEntities[_FirstUpdatedEntityProperties]); + // erase entity if needed + if( ( p->code & PROPERTY_CODE_ERASE ) != 0 ) + { + setDeleted( _FirstUpdatedEntityProperties ); + } + // RAZ code + p->code &= ~( PROPERTY_CODE_NEW | PROPERTY_CODE_ERASE ); + // RAZ bitfield + p->bitfield = 0; + // Remove it from list of updated entities + _FirstUpdatedEntityProperties = p->nextUpdatedEntityProperties; + p->nextUpdatedEntityProperties = -2; + } +} + +//--------------------------------------------------- +// Vision management : Set a new delta of vision +// +//--------------------------------------------------- +bool CFrontEndPropertyReceiver::setVision( const CEntityId& id, const map< NLMISC::CEntityId, TVisionSlot >& visionIn, const vector< NLMISC::CEntityId >& visionOut ) +{ + // Find the index + TPropertiesIndex iviewer = findIndex( id ); + if( iviewer == -1 ) + { + nlwarning( "Trouble when synchronising vision and properties: viewer not created" ); + return false; + } + + SEntity* p = &(_VectorEntities[iviewer]); + // If entity has no unprocessed vision + if( p->nextUpdatedEntityVision == -2 ) + { + // Insert the entity in the vision list + p->nextUpdatedEntityVision = _FirstUpdatedEntityVision; + _FirstUpdatedEntityVision = iviewer; + + for( map< CEntityId, TVisionSlot >::const_iterator itIn = visionIn.begin(); itIn != visionIn.end(); ++itIn ) + { + // Find the index of the id + TPropertiesIndex iviewed = findIndex( (*itIn).first ); + if( iviewed == -1 ) + { + // no synchronisation + nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision in and properties: viewed not inserted" ); + } + else + { + p->VisionIn.insert( make_pair( iviewed, (*itIn).second ) ); + } + } + + for( vector< NLMISC::CEntityId >::const_iterator itOut = visionOut.begin(); itOut != visionOut.end(); ++itOut ) + { + // Find the index of the id + TPropertiesIndex iviewed = findIndex( *itOut ); + if( iviewed == -1 ) + { + // no synchronisation + nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision out and properties: viewed not inserted" ); + } + else + { + p->VisionOut.insert( iviewed ); + } + } + } + else + { + // merging old and new delta vision update (only if front-end have not process previous vision update) + for( map< NLMISC::CEntityId, TVisionSlot >::const_iterator itIn = visionIn.begin(); itIn != visionIn.end(); ++itIn ) + { + // Find the index of the id + TPropertiesIndex iviewed = findIndex( (*itIn).first ); + if( iviewed == -1 ) + { + // no synchronisation + nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision in and properties: viewed not inserted" ); + } + else + { + p->VisionIn.insert( make_pair( iviewed, (*itIn).second ) ); + set< TPropertiesIndex >::iterator it = p->VisionOut.find( iviewed ); + if( it != p->VisionOut.end() ) + { + p->VisionOut.erase( it ); + } + } + } + + for( vector< NLMISC::CEntityId >::const_iterator itOut = visionOut.begin(); itOut != visionOut.end(); ++itOut ) + { + // Find the index of the id + TPropertiesIndex iviewed = findIndex( *itOut ); + if( iviewed == -1 ) + { + // no synchronisation + nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision out and properties: viewed not inserted" ); + } + else + { + p->VisionOut.insert( iviewed ); + map< TPropertiesIndex, TVisionSlot >::iterator it = p->VisionIn.find( iviewed ); + if( it != p->VisionIn.end() ) + { + p->VisionIn.erase( it ); + } + } + } + } + return true; +} + +//--------------------------------------------------- +// Vision management : Get the first modified vision since the last EndUpdatedVision +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getFirstUpdatedVision() +{ + return( _FirstUpdatedEntityVision ); +} + +//--------------------------------------------------- +// Vision management : Get the next modified vision +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getNextUpdatedVision( TPropertiesIndex indexprop ) +{ + return( _VectorEntities[indexprop].nextUpdatedEntityVision ); +} + +//--------------------------------------------------- +// Vision management : Call it after getting all the updated vision (eg, the.GetNextUpdatedVision function return -1 ) +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::endUpdatedVision() +{ + // for all the entities in the list of updated + while( _FirstUpdatedEntityVision != -1 ) + { + // Get the next entity + TPropertiesIndex i = _FirstUpdatedEntityVision; + SEntity* p = &(_VectorEntities[_FirstUpdatedEntityVision]); + // Clean the lists + p->VisionIn.clear(); + p->VisionOut.clear(); + // Remove it from list of updated entities + _FirstUpdatedEntityVision = p->nextUpdatedEntityVision; + p->nextUpdatedEntityVision = -2; + } +} + +//--------------------------------------------------- +// CEntityId / index management : Create a new index for the CEntityId +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::assignIndexToId( const CEntityId& id ) +{ + // insert a new elt + std::pair< TMapIdToIndex::iterator, bool> result = _MapIdToIndex.insert( TMapIdToIndex::value_type( id, _FirstFreeEntity ) ); + // if failed + if( !result.second ) + return( -1 ); + // if not, actualize _FirstFreeEntityProperties + TPropertiesIndex i = _FirstFreeEntity; + _FirstFreeEntity = _VectorEntities[i].nextFreeEntity; + return( i ); +} + +//--------------------------------------------------- +// CEntityId / index management : Release index / id association +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::releaseIndexToId( const NLMISC::CEntityId& id ) +{ + // find the index from the id + TMapIdToIndex::iterator it = _MapIdToIndex.find( id ); + if( it != _MapIdToIndex.end() ) + { + _MapIdToIndex.erase( it ); + } +} + +//--------------------------------------------------- +// CEntityId / index management : Get index, return true if finded and the value is setting. If false, value is undefined +// +//--------------------------------------------------- +CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::findIndex( const CEntityId& id ) +{ + // find the index from the id + TMapIdToIndex::iterator it = _MapIdToIndex.find( id ); + // if failed + if( it == _MapIdToIndex.end() ) + return( -1 ); + // if not + return( it->second ); +} + +//--------------------------------------------------- +// UpdateProperties, unserial update mirrors message and process it +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::updateProperties( CMessage& msgin ) +{ + //nlinfo("Received a properties update"); + + TPropertiesValue Value; + + while( (uint32)msgin.getPos () != msgin.length() ) + { + string PropertyName; + msgin.serial( PropertyName ); + + if( PropertyName == "Mode" ) + { + nlwarning("Mode updated"); + } + + CEntityId id; + msgin.serial( id ); + while( id != CEntityId::Unknown ) + { + Value = 0; + + uint32 indexProperty = 0; + + while( indexProperty < NB_PROPERTIES_PER_ENTITY ) + { + if( PropertiesProperty[ id.Type & 0x7f ] [ indexProperty ].PropertyName == PropertyName ) + { + switch( PropertiesProperty[ id.Type & 0x7f ] [ indexProperty ].PropertyType ) + { + case 0: // uint8 + { + uint8 v; + msgin.serial( v ); + Value = v; + } + break; + case 1: // sint8 + { + sint8 v; + msgin.serial( v ); + Value = v; + } + break; + case 2: // uint16 + { + uint16 v; + msgin.serial( v ); + Value = v; + } + break; + case 3: // sint16 + { + sint16 v; + msgin.serial( v ); + Value = v; + } + break; + case 4: // uint32 + { + uint32 v; + msgin.serial( v ); + Value = v; + } + break; + case 5: // sint32 + { + sint32 v; + msgin.serial( v ); + Value = v; + } + break; + case 6: // uint64 + { + uint64 v; + msgin.serial( v ); + Value = v; + } + break; + case 7: // sint64 + { + sint64 v; + msgin.serial( v ); + Value = v; + } + break; + case 8: // float + { + float v; + msgin.serial( v ); + *((float *)(&Value)) = v; + } + break; + case 9: // double + { + double v; + msgin.serial( v ); + *((double *)(&Value)) = v; + } + break; + + default: + nlwarning("Unknown type %d", PropertiesProperty[ id.Type & 0x7f ] [ indexProperty ].PropertyType ); + nlstop; + } + setProperties( id, indexProperty, Value ); + break; + } + + ++indexProperty; + + // if property is special property type, it's still code dependant at this time.... + if( indexProperty == NB_PROPERTIES_PER_ENTITY ) + { + if( PropertyName == string("TickPos") ) + { + TPropertiesIndex Index = findIndex( id ); + if( Index == 255 ) + { + Value = 0; + setProperties( id, x, Value ); // Create entity entry + Index = findIndex( id ); + } + msgin.serial( _VectorEntities[ Index ].TickPosition ); + } + else if( PropertyName == string("Sheet") ) + { + TPropertiesIndex Index = findIndex( id ); + if( Index == 255 ) + { + Value = 0; + setProperties( id, x, Value ); // Create entity entry + Index = findIndex( id ); + } + msgin.serial( _VectorEntities[ Index ].SheetId ); + } + } + } + msgin.serial( id ); + } + } +} + + /// +//--------------------------------------------------- +// RemoveEntity, unserial remove message and remove corresponding Entity +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::removeEntity( CMessage& msgin ) +{ + list< CEntityId > entityToRemove; + + msgin.serialCont( entityToRemove ); + + for( list< CEntityId >::iterator it = entityToRemove.begin(); it != entityToRemove.end(); ++it ) + { + deleteEntity( *it ); + } +} + +//--------------------------------------------------- +// UpdateVision, unserial update vision message and process it +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::updateVision( CMessage& msgin ) +{ + nlinfo("Received a vision update"); + list< SPlayerVisionDelta > deltaVision; + + msgin.serialCont( deltaVision ); + + for( list< SPlayerVisionDelta >::iterator it = deltaVision.begin(); it != deltaVision.end(); ++it ) + { + setVision( (*it).Id, (*it).EntityIn, (*it).EntityOut ); + } +} + +//--------------------------------------------------- +// Ask subscribe for one property +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::askPropertySubscribe( const string& ServiceSubscribe, const pair< string, uint32 >& Property ) +{ + CMessage msgOut( "PROPERTY_SUBSCRIBE" ); + string serviceSubscribe = ServiceSubscribe; + + string PropertyName = Property.first; + uint32 UpdateDelay = Property.second; + + msgOut.serial( PropertyName ); + msgOut.serial( UpdateDelay ); + CUnifiedNetwork::getInstance()->send( serviceSubscribe, msgOut ); + + nlinfo(" ask for property %s to service %s", PropertyName.c_str() , serviceSubscribe.c_str() ); +} + +//--------------------------------------------------- +// Ask subscribe for list of properties +// +//--------------------------------------------------- +void CFrontEndPropertyReceiver::askPropertiesSubscribe( const string& ServiceSubscribe, const list< pair< string, uint32 > >& Properties ) +{ + CMessage msgOut( "PROPERTIES_SUBSCRIBE" ); + uint16 numberProperty = Properties.size(); + msgOut.serial( numberProperty ); + + string PropertyName; + uint32 UpdateDelay; + for( list< pair< string, uint32 > >::const_iterator it = Properties.begin(); it != Properties.end(); ++it ) + { + PropertyName = (*it).first; + UpdateDelay = (*it).second; + msgOut.serial( PropertyName ); + msgOut.serial( UpdateDelay ); + nlinfo(" ask for property %s to service %s", PropertyName.c_str() , ServiceSubscribe.c_str() ); + } + CUnifiedNetwork::getInstance()->send( ServiceSubscribe, msgOut ); +} + +//--------------------------------------------------- +// Callback for delta mirror update received +// +//--------------------------------------------------- +void cbDeltaUpdate( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId ) +{ + CFrontEndPropertyReceiver::updateProperties( msgin ); +} + +// Callback for delta vision update remove received +void cbDeltaUpdateRemove( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId ) +{ + CFrontEndPropertyReceiver::removeEntity( msgin ); +} + +//--------------------------------------------------- +// Callback for delta vision update received +// +//--------------------------------------------------- +void cbDeltaVision( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId ) +{ + CFrontEndPropertyReceiver::updateVision( msgin ); +} + diff --git a/code/ryzom/tools/server/service_test/front_end_property_receiver.h b/code/ryzom/tools/server/service_test/front_end_property_receiver.h new file mode 100644 index 000000000..cbc1d2c05 --- /dev/null +++ b/code/ryzom/tools/server/service_test/front_end_property_receiver.h @@ -0,0 +1,246 @@ +/** \file front_end_property_receiver.h + * Container for manage property received by front end + * + * $Id: front_end_property_receiver.h,v 1.17 2004/03/01 19:22:19 lecroart Exp $ + */ + + + +#ifndef RY_FRONT_END_PROPERTY_RECEIVER_H +#define RY_FRONT_END_PROPERTY_RECEIVER_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/time_nl.h" +#include "nel/misc/path.h" +#include "nel/misc/entity_id.h" +#include "nel/georges/u_form_elm.h" +#include "nel/georges/u_form_loader.h" +#include "nel/net/service.h" + +#include +#include +#include +#include +#include + +#define NB_TYPE_ENTITIES 3 +#define NB_PROPERTIES_PER_ENTITY 16 +#define FE_NBMAX_ENTITIES 50000 +#define PROPERTY_CODE_ERASE 1<<31 +#define PROPERTY_CODE_NEW 1<<30 + +#define NB_OTHER_PROPERTIES 2 + +/** + * Manage delta received of property for front end + * \author Alain Saffray + * \author Nevrax France + * \date 2001 + */ +class CFrontEndPropertyReceiver +{ +public: + typedef uint32 TPropertiesBitfield; + typedef uint32 TPropertiesIndex; + typedef uint32 TPropertiesCode; + typedef uint32 TPropertiesContMask; + typedef uint64 TPropertiesValue; + typedef uint32 TPropertiesValueIndex; + typedef uint16 TVisionSlot; + typedef std::map< NLMISC::CEntityId, uint32 > TMapIdToIndex; + + struct SPropIndexCode + { + TPropertiesIndex index; + TPropertiesCode code; + }; + + struct SEntity + { + NLMISC::CEntityId id; // Entity Id + uint32 SheetId; // Id fiche of entity + TPropertiesCode code; // can be an "union" with bitfield and code => 3*32 bits -> 32 bits + TPropertiesBitfield bitfield; // can be an "union" with bitfield and code => 3*32 bits -> 32 bits + TPropertiesIndex nextFreeEntity; // can be an "union" with bitfield and code => 3*32 bits -> 32 bits + TPropertiesIndex nextUpdatedEntityProperties; + TPropertiesIndex nextUpdatedEntityVision; + TPropertiesContMask mask; + TPropertiesValue properties[NB_PROPERTIES_PER_ENTITY]; + NLMISC::TGameCycle TickPosition; + std::map< TPropertiesIndex, TVisionSlot > VisionIn; + std::set< TPropertiesIndex > VisionOut; + + /** + * Return GameCycle of property update + * \param PropertyIdx is property index + * \return Game cycle last update for property index + */ + NLMISC::TGameCycle getGameCycleForProperty( uint32 PropertyIdx ) { return TickPosition; } + }; + + struct SPropertyDesc + { + bool Continuous; // true if property is continuous type (FE not informed of changes) + bool Union; // true if property is with another in 64 bits property + std::string PropertyName; // name of property + std::string ServiceOwner; // name of owner service of property + uint8 UpdateFrequency;// Frequency of subcribtion updating (in number of ticks) + uint8 Index; // index of property (in array of property) + uint8 NbBits; // number of bits used by property + uint8 UnionShift; // bit shifting for union in 64 bits property destination + uint64 UnionMask; // mask for and/or operations for write property in 64 bits destination + uint8 PropertyType; // Type of property + }; + + struct SOtherPropertyDesc + { + std::string PropertyName; // name of property + std::string ServiceOwner; // name of owner service of property + uint8 NbBits; // number of bits used by property + uint8 UpdateFrequency;// Frequency of subcribtion updating (in number of ticks) + }; + + struct SIndexProperties + { + std::string PropertyName; + uint8 PropertyIndex; + }; + + enum EPropertyIndex { x = 0, y, z, theta, mode, behaviour, nameStringId }; + enum EntityTypeIndex { player = 0, unknown = 127 }; + +// static SIndexProperties PropertyIndexByType [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ]; + static SPropertyDesc PropertiesProperty [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ]; + static SOtherPropertyDesc OtherProperties [ NB_OTHER_PROPERTIES ]; + static uint32 PropertiesContinuousMask [ NB_TYPE_ENTITIES ]; + + /* + * Init of property receiver + *\param filename if georges sheet describe properties informations + */ + static void initFrontEndPropertyReceiver( const std::string& filenameProperties, const std::string& filenameEntityIndex ); + + /* + * Init entity index map with sheet + *\param pElt is a pointer on current element item of sheet + *\param EntityIndexMap is map association name of element ans it's index + */ + static void initEntityIndex( NLGEORGES::UFormElm *pElt, std::map< std::string, uint8 >& EntityIndexMap ); + + /* + * Init properties descriptor + *\Param pElt is a pointer on current element item of sheet + *\param EntityIndexMap is map association name of element ans it's index + *\param entityIndex is current index of entity + *\param ident is deep in tree structure + *\param itemNumber is idex/number of item in current deep tree structure + */ + static void initPropertyDescriptor( NLGEORGES::UFormElm *pElt, std::map< std::string, uint8 >& EntityIndexMap, uint32 ident = 0, uint32 itemNumber = 0, bool OtherProperty = false ); + + /// Init subscription for service up + static void initFrontEndPropertySubscription( const std::string& serviceName ); + + /// Remove entities in receiver when downing serviceID is owner + static void serviceDown( uint16 serviceId ); + + /// release data + static void freeFrontEndPropertyReceiver( void ); + + /// Entity management : called for deleting entities + static SEntity* getEntity( const TPropertiesIndex indexprop ); + + /// Property management : Set a new property + static bool setProperties( const NLMISC::CEntityId& id, uint32 indexvalue, TPropertiesValue& value ); + + /// Property management : Get the first modified properties since the last EndUpdatedProperties + static TPropertiesIndex getFirstUpdatedProperties(); + + /// Property management : Get the next modified properties + static TPropertiesIndex getNextUpdatedProperties( TPropertiesIndex indexprop ); + + /// Property management : Call it after getting all the updated properties (eg, the.GetNextUpdatedProperties function return -1 ) + static void endUpdatedProperties(); + + /// Vision management : Set a new delta of vision + static bool setVision( const NLMISC::CEntityId& id, const std::map< NLMISC::CEntityId, TVisionSlot >& visionIn, const std::vector< NLMISC::CEntityId >& visionOut ); + + /// Vision management : Get the first modified vision since the last EndUpdatedVision + static TPropertiesIndex getFirstUpdatedVision(); + + /// Vision management : Get the next modified vision + static TPropertiesIndex getNextUpdatedVision( TPropertiesIndex indexprop ); + + /// Vision management : Call it after getting all the updated vision (eg, the.GetNextUpdatedVision function return -1 ) + static void endUpdatedVision(); + + /// UpdateProperties, unserial update message and update corresponding properties + static void updateProperties( NLNET::CMessage& msgin ); + + /// RemoveEntity, unserial remove message and update corresponding Entity / properties + static void removeEntity( NLNET::CMessage& msgin ); + + /// UpdateProperties, unserial update message and update corresponding properties + static void updateVision( NLNET::CMessage& msgin ); + + /// Ask subscribe for one property + static void askPropertySubscribe( const std::string& ServiceSubscribe, const std::pair< std::string, uint32>& Property ); + + /// Ask subscribe for list of properties + static void askPropertiesSubscribe( const std::string& ServiceSubscribe, const std::list< std::pair< std::string, uint32 > >& Properties ); + +private: + static TPropertiesIndex _FirstFreeEntity; + static TPropertiesIndex _FirstUpdatedEntityProperties; + static TPropertiesIndex _FirstUpdatedEntityVision; + static std::vector< SEntity > _VectorEntities; + static TMapIdToIndex _MapIdToIndex; + + struct SPlayerVisionDelta + { + NLMISC::CEntityId Id; + std::vector< NLMISC::CEntityId > EntityOut; + std::map< NLMISC::CEntityId, TVisionSlot > EntityIn; + + void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + { + f.serial( Id ); + f.serialCont( EntityOut ); + f.serialCont( EntityIn ); + } + }; + + // CEntityId / index management : Create a new index for the CEntityId + static TPropertiesIndex assignIndexToId( const NLMISC::CEntityId& Id ); + + // CEntityId / index management : Get index, return true if finded and the value is setting. If false, value is undefined + static TPropertiesIndex findIndex( const NLMISC::CEntityId& id ); + + // CEntityId / index management : Release index / id association + static void releaseIndexToId( const NLMISC::CEntityId& id ); + + // Entity management : delete entity + static bool deleteEntity( const NLMISC::CEntityId& id ); + + // Entity management : called for deleting entities + static void setDeleted( TPropertiesIndex indexprop ); + + // init property with george's sheet + static void initPropertyDesc( NLGEORGES::UFormElm *pEltProperty, uint32 entity, uint32 property ); + + // Init entity other properties with george's sheet + static void initOtherPropertyDesc( NLGEORGES::UFormElm *pEltProperty ); + +}; + +// Callback for delta mirror update received +void cbDeltaUpdate( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId ); + +// Callback for delta vision update remove received +void cbDeltaUpdateRemove( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId ); + +// Callback for delta vision update received +void cbDeltaVision( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId ); + +#endif // RY_FRONT_END_PROPERTY_RECEIVER_H + +/* End of front_end_property_receiver.h */ diff --git a/code/ryzom/tools/server/service_test/service_test.cpp b/code/ryzom/tools/server/service_test/service_test.cpp new file mode 100644 index 000000000..f0e70cee3 --- /dev/null +++ b/code/ryzom/tools/server/service_test/service_test.cpp @@ -0,0 +1,256 @@ +/** \file service_test.cpp + * + * + * $Id: service_test.cpp,v 1.20 2004/03/01 19:22:19 lecroart Exp $ + */ + + + +#include "service_test.h" +#include "game_share/ryzom_entity_id.h" + +#include "nel/misc/command.h" +#include "nel/misc/path.h" + +#include "front_end_property_receiver.h" + +using namespace NLMISC; +using namespace NLNET; +using namespace NLGEORGES; +using namespace std; + +CServiceTest* pServiceTest = NULL; + +/** + * CallbackArray + */ +TUnifiedCallbackItem CallbackArray[] = +{ + { "AZERTY", NULL }, +}; + +// includes pour les register class qui suivent (grrrr !!!!) +#include "nel/georges/form_body_elt.h" +#include "nel/georges/form_body_elt_atom.h" +#include "nel/georges/form_body_elt_list.h" +#include "nel/georges/form_body_elt_struct.h" + +//--------------------------------------------------- +// Service Init : +// +//--------------------------------------------------- +void CServiceTest::init (void) +{ + // init obligatoire pour george (penser ŕ demander l'encapsulation de ça dans une methode init) + NLMISC_REGISTER_CLASS( CFormBodyElt ); + NLMISC_REGISTER_CLASS( CFormBodyEltAtom ); + NLMISC_REGISTER_CLASS( CFormBodyEltList ); + NLMISC_REGISTER_CLASS( CFormBodyEltStruct ); + + setUpdateTimeout(10); + pServiceTest = this; + +// DebugLog->addNegativeFilter(" "); + + // Define path where to search the sheets. + CPath::addSearchPath( "service_test_data/sheets", true, false ); + + CUnifiedNetwork::getInstance()->setServiceUpCallback ("*", cbServiceUp, NULL); + CUnifiedNetwork::getInstance()->setServiceDownCallback( string("*"), cbServiceDown, 0); + + CPath::addSearchPath( "fe_data/sheets", true, false ); + CFrontEndPropertyReceiver::initFrontEndPropertyReceiver( string("entity_prop.entity_prop"), string("rien") ); +} + +//--------------------------------------------------- +// Service update : +// +//--------------------------------------------------- +bool CServiceTest::update (void) +{ + serviceUpdate(); + return true; +} + +//--------------------------------------------------- +// Service release : +// +//--------------------------------------------------- +void CServiceTest::release (void) +{ + CFrontEndPropertyReceiver::freeFrontEndPropertyReceiver(); +} + +//--------------------------------------------------- +// Service release : +// +//--------------------------------------------------- +void CServiceTest::serviceUpdate(void) +{ + //----------------------------------------------- + // implementation d'exemple + // + //----------------------------------------------- + + // Read properties + uint64 value; + CFrontEndPropertyReceiver::TPropertiesIndex index = CFrontEndPropertyReceiver::getFirstUpdatedProperties(); + while( index != -1 ) + { + CFrontEndPropertyReceiver::SEntity* p = CFrontEndPropertyReceiver::getEntity( index ); + + bool is_new = ( ( p->code & PROPERTY_CODE_NEW ) != 0 ); // true = new entity + bool is_del = ( ( p->code & PROPERTY_CODE_ERASE ) != 0 ); // true = deleted entity + + if( is_new ) // Entity is new, we can read it's CEntityId and SheetId + { + nlinfo( "Entity %s is new, SheetId of entity is %d", p->id.toString().c_str(), p->SheetId ); + } + + if( is_del ) + { + nlinfo( "Entity %s is deleted", p->id.toString().c_str() ); + } + + uint32 mask = 1; + for( uint32 i = 0; i < NB_PROPERTIES_PER_ENTITY; ++i ) + { + if( p->bitfield & mask ) + { + value = p->properties[i]; //read here a modified property + + nlinfo( "Property %d of entity %s change to value %"NL_I64"d at TGameCyle %d", i, p->id.toString().c_str(), value, p->getGameCycleForProperty( i ) ); + } + mask <<= 1; + } + index = CFrontEndPropertyReceiver::getNextUpdatedProperties( index ); + } + CFrontEndPropertyReceiver::endUpdatedProperties(); + + // read vision + index = CFrontEndPropertyReceiver::getFirstUpdatedVision(); + uint32 sizeout = 0; + uint32 sizein = 0; + while( index != -1 ) + { + CFrontEndPropertyReceiver::SEntity* p = CFrontEndPropertyReceiver::getEntity( index ); + sizeout = p->VisionOut.size(); // p->VisionOut entities out of vision + sizein = p->VisionIn.size(); // p->VisionIn entities in of vision + if(sizeout != 0) + { + nlinfo("entity out of vision for entity %s", p->id.toString().c_str()); + for( set< CFrontEndPropertyReceiver::TPropertiesIndex >::iterator itOut = p->VisionOut.begin(); itOut != p->VisionOut.end(); ++itOut ) + { + CFrontEndPropertyReceiver::SEntity* pOut = CFrontEndPropertyReceiver::getEntity( *itOut ); + nlinfo("====> Entity exit of vision: %s", pOut->id.toString().c_str() ); + } + } + if(sizein != 0) + { + nlinfo("new entity in vision for entity %s", p->id.toString().c_str()); + for( map< CFrontEndPropertyReceiver::TPropertiesIndex, CFrontEndPropertyReceiver::TVisionSlot >::iterator itIn = p->VisionIn.begin(); itIn != p->VisionIn.end(); ++itIn ) + { + CFrontEndPropertyReceiver::SEntity* pIn = CFrontEndPropertyReceiver::getEntity( (*itIn).first ); + nlinfo("====> Entity enter in vision: %s to Slot %d", pIn->id.toString().c_str(), (*itIn).second ); + } + } + + index = CFrontEndPropertyReceiver::getNextUpdatedVision( index ); + } + CFrontEndPropertyReceiver::endUpdatedVision(); +} + +/****************************************************************\ + **************************************************************** + Callback functions + **************************************************************** +\****************************************************************/ +// Callback called at service connexion +void cbServiceUp( const string& serviceName, uint16 serviceId, void * ) +{ + CFrontEndPropertyReceiver::initFrontEndPropertySubscription( serviceName ); +} + +// Callback called at service down +void cbServiceDown( const string& serviceName, uint16 serviceId, void * ) +{ + CFrontEndPropertyReceiver::serviceDown( serviceId ); +} + + +/****************************************************************\ + **************************************************************** + Service register + **************************************************************** +\****************************************************************/ +NLNET_SERVICE_MAIN (CServiceTest, "ServiceTest", "service_test", 0, CallbackArray, "", "") + + +/****************************************************************\ + **************************************************************** + Command section + **************************************************************** +\****************************************************************/ +// Command for display data changed to receiver +NLMISC_COMMAND(subscribe,"Subscribe to delta update"," ") +{ + // Define path where to search the sheets. +// CPath::addSearchPath( "service_test_data/sheets", true, false ); +// CFrontEndPropertyReceiver::initFrontEndPropertyReceiver( string("entity_prop.entity_prop") ); + + list< pair< string, uint32 > > Properties; + Properties.push_back( make_pair( string("X"), 0x00000001 ) ); + Properties.push_back( make_pair( string("Y"), 0x00000001 ) ); + Properties.push_back( make_pair( string("Z"), 0x00000001 ) ); + Properties.push_back( make_pair( string("Theta"), 0x00000001 ) ); + CFrontEndPropertyReceiver::askPropertiesSubscribe( string("GPMS"), Properties ); + + return true; +} + + + + + +// Command to add an entity to the GPMS +NLMISC_COMMAND(addEntity,"Add entity to GPMS","entity Id, entity PosX(meters), entity PosY, entity PosZ, service Id") +{ + // check args, if there s not the right number of parameter, return bad + if(args.size() != 5) return false; + + // get the values + uint32 Id = atoi(args[0].c_str()); + uint32 PosX = atoi(args[1].c_str()) * 1000; + uint32 PosY = atoi(args[2].c_str()) * 1000; + sint32 PosZ = atoi(args[3].c_str()) * 1000; + + uint16 FeId = atoi(args[4].c_str()); + + // Init Entity + CEntityId id; + id.Type = RYZOMID::player; + id.Id = Id; + id.DynamicId = FeId; + +// CWorldPositionManager::addEntity(id, 1000 * PosX, 1000*PosY, 1000*PosZ, 0.0f, CTickEventHandler::getGameCycle() - 1/*CTickEventHandler::getGameCycles()*/,/*sheet*/0,FeId); + CMessage msgout("ADD_ENTITY"); + + msgout.serial( id ); + + msgout.serial( PosX ); + msgout.serial( PosY ); + msgout.serial( PosZ ); + float theta = 0.0f; + msgout.serial( theta ); + + NLMISC::TGameCycle tick = 0; +// tick = CTickEventHandler::getGameCycle(); + msgout.serial( tick ); + uint32 sheet = 0; + msgout.serial( sheet ); + + + CUnifiedNetwork::getInstance()->send( "GPMS", msgout ); + + return true; +} diff --git a/code/ryzom/tools/server/service_test/service_test.h b/code/ryzom/tools/server/service_test/service_test.h new file mode 100644 index 000000000..65d810752 --- /dev/null +++ b/code/ryzom/tools/server/service_test/service_test.h @@ -0,0 +1,50 @@ +/** \file service_test.h + * + * + * $Id: service_test.h,v 1.7 2004/03/01 19:22:19 lecroart Exp $ + */ + + + + +#ifndef GD_SERVICE_TEST_H +#define GD_SERVICE_TEST_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/time_nl.h" +#include "nel/net/service.h" + +#include "front_end_property_receiver.h" + +// Callback called at service connexion +void cbServiceUp( const std::string& serviceName, uint16 serviceId, void * ); + +// Callback called at service down +void cbServiceDown( const std::string& serviceName, uint16 serviceId, void * ); + +/** + * + * \author Guillaume PUZIN + * \author Nevrax France + * \date 2001 + */ +class CServiceTest : public NLNET::IService +{ +public: + // Initialisation of service + void init (void); + + // Update net processing + bool update (void); + + // Update service processing + void serviceUpdate(void); + + // Release the service + void release (void); +}; + +#endif // GD_SERVICE_TEST_H + + +/* End of service_test.h */ diff --git a/code/ryzom/tools/server/test/backup_service_interface_test.cpp b/code/ryzom/tools/server/test/backup_service_interface_test.cpp new file mode 100644 index 000000000..430bcf7de --- /dev/null +++ b/code/ryzom/tools/server/test/backup_service_interface_test.cpp @@ -0,0 +1,214 @@ +/* + backup_service_interface test + + project: RYZOM / TEST +*/ + +#include "nel/misc/variable.h" +#include "game_share/backup_service_interface.h" +#include "game_share/singleton_registry.h" + +using namespace std; +using namespace NLMISC; + +class CBackupFileReceiveCallbackTest: public IBackupFileReceiveCallback +{ +public: + virtual void callback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) + { + std::string s; + dataStream.serial(s); + nlinfo("Received file: %s (timestamp:%d, size:%d) containing string: %s",fileDescription.FileName.c_str(),fileDescription.FileTimeStamp,fileDescription.FileSize,s.c_str()); + } + + ~CBackupFileReceiveCallbackTest() + { + nlinfo("~CBackupFileReceiveCallbackTest()"); + } +}; + +class CBackupFileListReceiveCallbackTest: public IBackupFileListReceiveCallback +{ +public: + virtual void callback(const CFileDescriptionContainer& fileList) + { + nlinfo("Received file list"); + fileList.display(NLMISC::InfoLog); + } + + ~CBackupFileListReceiveCallbackTest() + { + nlinfo("~CBackupFileListReceiveCallbackTest()"); + } +}; + +extern NLMISC::CVariable UseBS; + +class CBackupServiceInterfaceTest: public IServiceSingleton +{ +public: + void init() + { + + // *** TODO !!!! *** + // need to ensure that BS interface internals are OK - the queues should be empty here... + } +}; + +static CBackupServiceInterfaceTest Test; + +NLMISC_COMMAND(backupTestRequestFile,"","") +{ + bool oldUseBS= UseBS; + + // test CBackupServiceInterface::requestFile() + { + UseBS= true; + nlinfo("----- request file using BS -----"); + Bsi.requestFile("backup_service_interface_test0.bin",new CBackupFileReceiveCallbackTest); + + UseBS= false; + nlinfo("----- request file no BS -----"); + Bsi.requestFile("backup_service_interface_test1.bin",new CBackupFileReceiveCallbackTest); + } + + nlinfo("----- END OF REQUEST FILE TEST -----"); + UseBS= oldUseBS; + return true; +} + +NLMISC_COMMAND(backupTestRequestFileList,"","") +{ + bool oldUseBS= UseBS; + + // test CBackupServiceInterface::requestFileList() + { + UseBS= true; + nlinfo("----- request file list using BS => * -----"); + Bsi.requestFileList("data_shard", new CBackupFileListReceiveCallbackTest); + nlinfo("----- request file list using BS => egs* -----"); + Bsi.requestFileList("data_shard", "egs*", new CBackupFileListReceiveCallbackTest,true); + + std::vector vect; + vect.push_back("ais*"); + vect.push_back("*.rbank"); + nlinfo("----- request file list using BS => ais*,*.rbank -----"); + Bsi.requestFileList("data_shard", vect, new CBackupFileListReceiveCallbackTest,true); + + UseBS= false; + nlinfo("----- request file list no BS -----"); + Bsi.requestFileList("data_shard", new CBackupFileListReceiveCallbackTest); + } + + nlinfo("----- END OF REQUEST FILE LIST TEST -----"); + UseBS= oldUseBS; + return true; +} + +NLMISC_COMMAND(backupTestSendFile,"","") +{ + bool oldUseBS= UseBS; + + // test CBackupServiceInterface::sendFile() + { + std::string s ="Hello World"; + + UseBS= true; + nlinfo("----- save file using BS => backup_service_interface_test0.bin -----"); + CBackupMsgSaveFile saveFileMsg("backup_service_interface_test0.bin", CBackupMsgSaveFile::SaveFile, Bsi ); + saveFileMsg.DataMsg.serial(s); + saveFileMsg.DataMsg.serial(s); + Bsi.sendFile(saveFileMsg); + + UseBS= false; + nlinfo("----- save file no BS => backup_service_interface_test1.bin -----"); + CBackupMsgSaveFile saveFileMsg2("backup_service_interface_test1.bin", CBackupMsgSaveFile::SaveFile, Bsi ); + saveFileMsg2.DataMsg.serial(s); + saveFileMsg2.DataMsg.serial(s); + Bsi.sendFile(saveFileMsg2); + } + + nlinfo("----- END OF SEND FILE TEST -----"); + UseBS= oldUseBS; + return true; +} + +NLMISC_COMMAND(backupTestOutputStream,"","") +{ + bool oldUseBS= UseBS; + + // test CBackupOutputStream - with BS + { + UseBS=true; + CBackupOutputStream outputStream("backup_service_interface_test2.bin","remote_","local_"); + NLMISC::IStream& stream= outputStream.getStream(); + std::string s="CBackupOutputStream test - with BS"; + stream.serial(s); + } + + // test CBackupOutputStream - without BS + { + UseBS=false; + CBackupOutputStream outputStream("backup_service_interface_test3.bin","remote_","local_"); + NLMISC::IStream& stream= outputStream.getStream(); + std::string s="CBackupOutputStream test- without BS"; + stream.serial(s); + } + + nlinfo("----- END OF OUTPUT STREAM TEST -----"); + UseBS= oldUseBS; + return true; +} + + + + + + + + + + + + + +CBackupServiceInterface BSInterface; + +void cbBackupAppend(CBackupMsgAppendCallback& append) +{ + uint i; + for (i=0; i") +{ + if (args.size()!=1) + return false; + + std::map result; + + FILE *inf=fopen(args[0].c_str(),"rb"); + if (inf==NULL) + { + nlwarning("Failed to open file: %s",args[0].c_str()); + return false; + } + + CSString input; + input.resize(CFile::getFileSize(inf)); + uint32 bytesRead= fread(&input[0],1,input.size(),inf); + fclose(inf); + if (bytesRead!=input.size()) + { + nlwarning("Failed to read contents of file: %s",args[0].c_str()); + return false; + } + + while(!input.empty()) + { + CSString line=input.firstLine(true); + if () + continue; + CSString account= line.first + CSString + } + + const char* outputName= "c:/banned_names.xml"; + nlinfo("Writing output: %s",outputName); + try + { + COFile f; + f.open(outputName); + COXml fx; + fx.init(&f,"1.0"); + fx.serialCont(result); + fx.flush(); + f.close(); + } + catch(...) + { + nlinfo("Problem with output file: %s",outputName); + } + + return true; +} + +NLMISC_COMMAND(buildReservedNameListFromFile,"","") +{ + if (args.size()!=1) + return false; + + std::map result; + + + const char* outputName= "c:/reserved_names.xml"; + nlinfo("Writing output: %s",outputName); + try + { + COFile f; + f.open(outputName); + COXml fx; + fx.init(&f,"1.0"); + fx.serialCont(result); + fx.flush(); + f.close(); + } + catch(...) + { + nlinfo("Problem with output file: %s",outputName); + } + + return true; +} + +NLMISC_COMMAND(buildReservedNameListFromBinFiles,"","[...]") +{ + if (args.size()<1) + return false; + + CFileDescriptionContainer fdc; + for (uint32 j=0;j TMyMap; + TMyMap myMap; + + for (uint32 i=0;iFileTimeStamp>fdc[i].FileTimeStamp) + continue; + } + myMap[fileName]= &fdc[i]; + } + + std::map result; + uint32 lastAccount=~0u; + for (TMyMap::iterator it=myMap.begin();it!=myMap.end();++it) + { + CSString s= (*it).first; + s.strtok("_"); + uint32 account=s.strtok("_").atoi(); + + if (account!=lastAccount) + { + lastAccount=account; + + try + { + CIFile f; + ucstring ucs; + f.open((*it).second->FileName); + f.seek(18,NLMISC::IStream::begin); + f.serial(ucs); + f.close(); + result[ucs]=account; + nlinfo("%s: name: %s",(*it).second->FileName.c_str(),ucs.toUtf8().c_str()); + } + catch(...) + { + nlinfo("Problem with: %s",(*it).second->FileName.c_str()); + } + } + } + + const char* outputName= "c:/reserved_names_from_bin_files.xml"; + nlinfo("Writing output: %s",outputName); + try + { + COFile f; + f.open(outputName); + COXml fx; + fx.init(&f,"1.0"); + fx.serialCont(result); + fx.flush(); + f.close(); + } + catch(...) + { + nlinfo("Problem with output file: %s",outputName); + } + + return true; +} diff --git a/code/ryzom/tools/server/test/file_description_container_test.cpp b/code/ryzom/tools/server/test/file_description_container_test.cpp new file mode 100644 index 000000000..041848125 --- /dev/null +++ b/code/ryzom/tools/server/test/file_description_container_test.cpp @@ -0,0 +1,53 @@ +/* + file_description_container test + + project: RYZOM / TEST +*/ + +#include "nel/misc/file.h" +#include "game_share/file_description_container.h" +#include "game_share/singleton_registry.h" + +using namespace std; +using namespace NLMISC; + +class CFileDescriptionTest: public IServiceSingleton +{ +public: + void init() + { + CFileDescriptionContainer fdc; + nlassert(fdc.empty()); + + fdc.addFile("some file that doesn't exist 0"); + fdc.addFile("some file that doesn't exist 1",0,0); + fdc.addFileSpec("some file that doesn't exist 2"); + nlassert(!fdc.empty()); + + fdc.addFileSpec("*"); + + for (uint32 i=0;i ") +{ + if (args.size()!=2) + return false; + + CPersistentDataRecord pdr; + pdr.readFromBinFile(args[0].c_str()); + pdr.writeToTxtFile(args[1].c_str()); + + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,pdrXml2bin,"convert a text pdr file to binary"," ") +{ + if (args.size()!=2) + return false; + + CPersistentDataRecord pdr; + pdr.readFromTxtFile(args[0].c_str()); + pdr.writeToBinFile(args[1].c_str()); + + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,quickFileCompare,"compare 2 files (by comparing timestamp and size)"," ") +{ + if (args.size()!=2) + return false; + + log.displayNL("comparing files ..."); + bool result= NLMISC::CFile::quickFileCompare(args[0], args[1]); + log.displayNL("- %s",result?"Same":"Different"); + + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,thoroughFileCompare,"compare 2 files (by comparing data)"," []") +{ + if (args.size()!=2 && args.size()!=3) + return false; + + bool result; + log.displayNL("comparing files ..."); + + if (args.size()==3) + { + uint32 size=atoi(args[2].c_str()); + if (size<2) + { + log.displayNL("The third parameter must be a value >= 2 : The following value is not valid: %s",args[2].c_str()); + return true; + } + result= NLMISC::CFile::thoroughFileCompare(args[0], args[1], size); + } + else + { + result= NLMISC::CFile::thoroughFileCompare(args[0], args[1]); + } + + log.displayNL("- %s",result?"Same":"Different"); + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,cd,"change directory or display current working directory","[]") +{ + if (args.size()!=0 && args.size()!=1) + return false; + + if (args.size()==1) + { + NLMISC::CPath::setCurrentPath(args[0].c_str()); + } + + log.displayNL("Current directory: %s",NLMISC::CPath::getCurrentPath().c_str()); + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,md,"create a new directory (or directory tree)","") +{ + if (args.size()!=1) + return false; + + NLMISC::CFile::createDirectoryTree(args[0]); + + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,copyFile,"copy a file"," ") +{ + if (args.size()!=2) + return false; + + NLMISC::CFile::copyFile(args[1].c_str(),args[0].c_str()); + + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,del,"delete a file","") +{ + if (args.size()!=1) + return false; + + NLMISC::CFile::deleteFile(args[0]); + + return true; +} + +NLMISC_CATEGORISED_COMMAND(utils,dir,"list files in the current directory","[]") +{ + if (args.size()!=1 && args.size()!=0) + return false; + + std::string wildcard="*"; + if (args.size()==1) + wildcard=args[0]; + + std::vector directories; + NLMISC::CPath::getPathContent(".",false,true,false,directories); + for (uint32 i=directories.size();i--;) + { + if (!NLMISC::testWildCard(directories[i],wildcard)) + { + directories[i]=directories.back(); + directories.pop_back(); + } + } + std::sort(directories.begin(),directories.end()); + for (uint32 i=0;i files; + NLMISC::CPath::getPathContent(".",false,false,true,files); + for (uint32 i=files.size();i--;) + { + if (!NLMISC::testWildCard(files[i],wildcard)) + { + files[i]=files.back(); + files.pop_back(); + } + } + std::sort(files.begin(),files.end()); + for (uint32 i=0;i=20) + { + count=0; + if (!NLMISC::CFile::fileExists("patch_test/test0/test_package.wip")) + processPackage("patch_test/test0/test_package.xml"); + else + nlinfo("skipping 'process package' because test_package.wip 'work in progress' marker exists"); + } + } + + static bool createPackage(std::string fileName) + { + // normalise the file name (and path) + normalisePackageDescriptionFileName(fileName); + + // make sure the file doesn't exist + BOMB_IF(NLMISC::CFile::fileExists(fileName),("Failed to careate new package because file already exists: "+fileName).c_str(),return false); + + // create the directory tree required for the file + NLMISC::CFile::createDirectoryTree(NLMISC::CFile::getPath(fileName)); + + // create a new package, store it to a persistent data record and write the latter to a file + CPackageDescription package; + CPersistentDataRecord pdr; + package.storeToPdr(pdr); + pdr.writeToTxtFile(fileName.c_str()); + package.setup(fileName); + package.createDirectories(); + package.buildDefaultFileList(); + package.storeToPdr(pdr); + pdr.writeToTxtFile(fileName.c_str()); + BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to create new package file: "+fileName).c_str(),return false); + nlinfo("New package description file created successfully: %s",fileName.c_str()); + + return true; + } + + static bool processPackage(std::string fileName) + { + // normalise the file name (and path) + normalisePackageDescriptionFileName(fileName); + + // make sure the file exists + BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to process package because file not found: "+fileName).c_str(),return false); + + // read the package description file + CPackageDescription thePackage; + thePackage.setup(fileName); + + // read the index file for the package + CBNPFileSet packageIndex; + thePackage.readIndex(packageIndex); + + // update the files list in the index + thePackage.updateIndexFileList(packageIndex); + + // update the index for the package + thePackage.addVersion(packageIndex); + + // save the updated index file + thePackage.writeIndex(packageIndex); + + // generate patches as required + thePackage.generatePatches(packageIndex); + + // generate client index file + CPackageDescriptionForClient theClientPackage; + thePackage.generateClientIndex(theClientPackage,packageIndex); + + return true; + } +}; + +static CPatchTest PatchTest; + +NLMISC_COMMAND(createPackage,"create a new package description file","") +{ + if (args.size()!=1) + return false; + + PatchTest.createPackage(args[0]); + + return true; +} + +NLMISC_COMMAND(processPackage,"process a package","") +{ + if (args.size()!=1) + return false; + + PatchTest.processPackage(args[0]); + + return true; +} + +NLMISC_COMMAND(bin2xml,"convert a binary pdr file to xml"," ") +{ + if (args.size()!=2) + return false; + + CPersistentDataRecord pdr; + pdr.readFromBinFile(args[0].c_str()); + pdr.writeToTxtFile(args[1].c_str()); + + return true; +} + diff --git a/code/ryzom/tools/server/test/persistent_data_test.cpp b/code/ryzom/tools/server/test/persistent_data_test.cpp new file mode 100644 index 000000000..180083313 --- /dev/null +++ b/code/ryzom/tools/server/test/persistent_data_test.cpp @@ -0,0 +1,1117 @@ +/* + Persistent data system test + + project: RYZOM / TEST + +*/ + +//----------------------------------------------------------------------------- +// includes +//----------------------------------------------------------------------------- + +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" +#include "nel/misc/command.h" +#include "nel/net/message.h" +#include "game_share/singleton_registry.h" +#include "game_share/persistent_data.h" +#include "game_share/persistent_data_tree.h" +#include "game_share/backup_service_interface.h" + +//#include "pd_lib/pd_string_manager.h" + + +//----------------------------------------------------------------------------- +// setup definitions used by PDR system +//----------------------------------------------------------------------------- + +#define PERSISTENT_MACROS_AUTO_UNDEF + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass_Struct +//----------------------------------------------------------------------------- + +class CMyPersistentClass_Struct +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass_Struct() + { + } + + CMyPersistentClass_Struct(std::string s0,std::string s1) + { + _S0=s0; + _S1=s1; + } + + void clear() + { + _S0.clear(); + _S1.clear(); + } + +private: + std::string _S0,_S1; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass_Struct +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass_Struct +#define PERSISTENT_DATA\ + PROP(std::string,_S0)\ + PROP(std::string,_S1) + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// setup token family definition used by PDR system +//----------------------------------------------------------------------------- + +// note - this is defined here and not above so as to test the case where a sub-class +// such as CMyPersistentClass_Struct is built outside the token family + +#define PERSISTENT_TOKEN_FAMILY TestTokenFamily + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass +//----------------------------------------------------------------------------- + +class CMyPersistentClass +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass() + { + static uint32 counter=0; + counter+=100; + + b = (counter%200)!=0; + ui8 = ((uint8)counter)+8; + ui16 = ((uint16)counter)+16; + ui32 = counter+32; + ui64 = counter+64; + si8 = ((sint8)counter)+9; + si16 = ((sint16)counter)+17; + si32 = counter+33; + si64 = counter+65; + f = (float)counter+123.456f; + d = counter+987.654; + s = NLMISC::toString("Testing...%d",counter); + ucs = (ucstring)NLMISC::toString("Tésting UCString ...%d",counter); + sid = NLMISC::CSheetId(); + eid = NLMISC::CEntityId(); + mpcs = CMyPersistentClass_Struct("hello",NLMISC::toString("World...%d",counter)); + mpcpv.push_back(counter+0); + mpcpv.push_back(counter+1); + mpcpv.push_back(counter+2); + mpcsv.push_back(CMyPersistentClass_Struct("one",NLMISC::toString("two...%d",counter))); + mpcsv.push_back(CMyPersistentClass_Struct("three",NLMISC::toString("four...%d",counter))); + mpcpm["mapOne"]=counter-1; + mpcpm["mapTwo"]=counter-2; + mpcsm["mappyOne"]=CMyPersistentClass_Struct(NLMISC::toString("one...%d",counter),"one"); + mpcsm["mappyTwo"]=CMyPersistentClass_Struct(NLMISC::toString("two...%d",counter),"two"); + } + +private: + bool b; + uint8 ui8; + uint16 ui16; + uint32 ui32; + uint64 ui64; + sint8 si8; + sint16 si16; + sint32 si32; + sint64 si64; + float f; + double d; + std::string s; + ucstring ucs; + NLMISC::CSheetId sid; + NLMISC::CEntityId eid; + + CMyPersistentClass_Struct mpcs; + std::vector mpcpv; + std::vector mpcsv; + std::map mpcpm; + std::map mpcsm; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass +#define PERSISTENT_DATA\ + PROP(bool,b)\ + PROP(uint8,ui8)\ + PROP(uint16,ui16)\ + PROP(uint32,ui32)\ + PROP(uint64,ui64)\ + PROP(sint8,si8)\ + PROP(sint16,si16)\ + PROP(sint32,si32)\ + PROP(sint64,si64)\ + PROP(float,f)\ + PROP(double,d)\ + PROP(std::string,s)\ + PROP2(ucs,std::string,ucs.toUtf8(),ucs.fromUtf8(val))\ + PROP(NLMISC::CSheetId,sid)\ + PROP(NLMISC::CEntityId,eid)\ + STRUCT(mpcs)\ + PROP_VECT(uint32,mpcpv)\ + STRUCT_VECT(mpcsv)\ + PROP_MAP(std::string,uint32,mpcpm)\ + STRUCT_MAP(std::string,CMyPersistentClass_Struct,mpcsm) + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass2 +//----------------------------------------------------------------------------- + +class CMyPersistentClass2 +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass2() + { + static uint32 counter=0; + counter+=100; + + s0 = NLMISC::toString("MPC2 0...%d",counter); + s1 = NLMISC::toString("MPC2 1...%d",counter); + } + +private: + std::string s0, s1; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass2 +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass2 +#define PERSISTENT_DATA\ + PROP(std::string,s0)\ + PROP(std::string,s1)\ + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass3 +//----------------------------------------------------------------------------- + +class CMyPersistentClass3 +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass3() + { + static uint32 counter=0; + counter+=100; + + s0 = NLMISC::toString("MPC3 0...%d",counter); + s1 = NLMISC::toString("MPC3 1...%d",counter); + i0 = counter + 1; + i1 = counter + 2; + i2 = counter + 3; + } + +private: + std::string s0, s1; + uint32 i0, i1, i2; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass3 +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass3 +#define PERSISTENT_DATA\ + PROP(uint32,i0)\ + PROP(std::string,s0)\ + PROP(uint32,i1)\ + PROP(std::string,s1)\ + PROP(uint32,i2)\ + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass4 +//----------------------------------------------------------------------------- + +class CMyPersistentClass4 +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass4() + { + static uint32 counter=0; + counter+=100; + + s0 = NLMISC::toString("MPC4 0...%d",counter); + s1 = NLMISC::toString("MPC4 1...%d",counter); + mpcsm["mappyOne"]=CMyPersistentClass_Struct(NLMISC::toString("MPC4 one...%d",counter),"MPC4 one"); + mpcsm["mappyTwo"]=CMyPersistentClass_Struct(NLMISC::toString("MPC4 two...%d",counter),"MPC4 two"); + } + +private: + std::string s0, s1; + std::map mpcsm; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass4 +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass4 +#define PERSISTENT_DATA\ + PROP(std::string,s0)\ + STRUCT_MAP(std::string,CMyPersistentClass_Struct,mpcsm)\ + PROP(std::string,s1)\ + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass5 +//----------------------------------------------------------------------------- + +class CMyPersistentClass5 +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass5() + { + ui8= (uint8(~0))^ ((uint8(~0))>>1); + ui16= (uint16(~0))^ ((uint16(~0))>>1); + ui32= (uint32(~0))^ ((uint32(~0))>>1); + ui64= (uint64(~0))^ ((uint64(~0))>>1); + + si8= (sint8)ui8; + si16= (sint16)ui16; + si32= (sint32)ui32; + si64= (sint64)ui64; + + f0=(float)ui64; + f1=(float)si64; + d0=(double)ui64; + d1=(double)si64; + } + +private: + uint8 ui8; + uint16 ui16; + uint32 ui32; + uint64 ui64; + sint8 si8; + sint16 si16; + sint32 si32; + sint64 si64; + float f0,f1; + double d0,d1; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass5 +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass5 +#define PERSISTENT_DATA\ + PROP(uint8,ui8)\ + PROP(uint16,ui16)\ + PROP(uint32,ui32)\ + PROP(uint64,ui64)\ + PROP(sint8,si8)\ + PROP(sint16,si16)\ + PROP(sint32,si32)\ + PROP(sint64,si64)\ + PROP(float,f0)\ + PROP(float,f1)\ + PROP(double,d0)\ + PROP(double,d1)\ + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass6 +//----------------------------------------------------------------------------- + +class CMyPersistentClass6 +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass6() + { + ui8= 0.0; + ui16= 0.0; + ui32= 0.0; + ui64= 0.0; + + si8= 0.0; + si16= 0.0; + si32= 0.0; + si64= 0.0; + + f0= 0; + f1= 0; + d0= 0; + d1= 0; + } + +private: + double ui8; + double ui16; + double ui32; + double ui64; + double si8; + double si16; + double si32; + double si64; + uint64 f0,d0; + sint64 f1,d1; +}; + + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass6 +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass6 +#define PERSISTENT_DATA\ + PROP(double,ui8)\ + PROP(double,ui16)\ + PROP(double,ui32)\ + PROP(double,ui64)\ + PROP(double,si8)\ + PROP(double,si16)\ + PROP(double,si32)\ + PROP(double,si64)\ + PROP(uint64,f0)\ + PROP(sint64,f1)\ + PROP(uint64,d0)\ + PROP(sint64,d1)\ + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMyPersistentClass7 +//----------------------------------------------------------------------------- + +class CMyPersistentClass7 +{ +public: + DECLARE_PERSISTENCE_METHODS + +public: + CMyPersistentClass7(): + struct2("struct2_0","struct2_1"), + lstructa("lstructa_0","lstructa_1"), + lstructb("lstructb_0","lstructb_1"), + lstruct2a("lstruct2a_0","lstruct2a_1"), + lstruct2b("lstruct2b_0","lstruct2b_1") + { + static uint32 version=0; + + prop2 = "prop2"; + lpropa = "lpropa"; + lpropb = "lpropb"; + lprop2a = "lprop2a"; + lprop2b = "lprop2b"; + + propSet.insert("propSet_0"); + propSet.insert("propSet_1"); + + lpropVect.push_back("lpropVect_0"); + lpropVect.push_back("lpropVect_1"); + + lpropVect2.push_back("lpropVect2_0"); + lpropVect2.push_back("lpropVect2_1"); + + structPtrVect.push_back(new CMyPersistentClass_Struct("structPtrVect_0","structPtrVect_0_0")); + structPtrVect.push_back(new CMyPersistentClass_Struct("structPtrVect_1","structPtrVect_1_1")); + + propArray.push_back("a"); + propArray.push_back("b"); + if ((version&1)==0) + propArray.push_back("c - optional"); + + structArray.push_back(CMyPersistentClass_Struct("structPtrVect_0","structPtrVect_0_0")); + structArray.push_back(CMyPersistentClass_Struct("structPtrVect_1","structPtrVect_1_1")); + if ((version&1)==1) + structArray.push_back(CMyPersistentClass_Struct("structPtrVect_2 - optional","structPtrVect_2_2 - optional")); + + version++; + } + + void clear() + { + prop2.clear(); + lpropa.clear(); + lpropb.clear(); + lprop2a.clear(); + lprop2b.clear(); + + struct2.clear(); + lstructa.clear(); + lstructb.clear(); + lstruct2a.clear(); + lstruct2b.clear(); + + propSet.clear(); + lpropVect.clear(); + lpropVect2.clear(); + structPtrVect.clear(); + } + +private: + std::string prop2; + std::string lpropa; + std::string lpropb; + std::string lprop2a; + std::string lprop2b; + + CMyPersistentClass_Struct struct2; + CMyPersistentClass_Struct lstructa; + CMyPersistentClass_Struct lstructb; + CMyPersistentClass_Struct lstruct2a; + CMyPersistentClass_Struct lstruct2b; + + std::set propSet; + + std::vector lpropVect; + std::vector lpropVect2; + + std::vector propArray; + std::vector structArray; + + std::vector structPtrVect; +}; + +//----------------------------------------------------------------------------- +// Persistent data for CMyPersistentClass7 +//----------------------------------------------------------------------------- + +#define PERSISTENT_CLASS CMyPersistentClass7 + +#define PERSISTENT_PRE_STORE nlinfo("PERSISTENT_PRE_STORE"); +#define PERSISTENT_PRE_APPLY nlinfo("PERSISTENT_PRE_APPLY"); +#define PERSISTENT_POST_STORE nlinfo("PERSISTENT_POST_STORE"); +#define PERSISTENT_POST_APPLY nlinfo("PERSISTENT_POST_APPLY"); + +#define PERSISTENT_DATA\ + FLAG(flag,nlinfo("flag");clear())\ + PROP2(prop2,std::string,prop2,prop2=val)\ + LPROP(std::string,lpropa,if(true))\ + LPROP(std::string,lpropb,if(false))\ + LPROP2(lprop2a,std::string,if(true),lprop2a,lprop2a=val)\ + LPROP2(lprop2b,std::string,if(false),lprop2b,lprop2b=val)\ + PROP_SET(std::string,propSet)\ + LPROP_VECT(std::string,lpropVect,VECT_LOGIC(lpropVect))\ + LPROP_VECT2(lpropVect2,std::string,VECT_LOGIC(lpropVect2),lpropVect2[i],lpropVect2.push_back(val))\ + STRUCT2(struct2,struct2.store(pdr),struct2.apply(pdr))\ + LSTRUCT(lstructa,if(true))\ + LSTRUCT(lstructb,if(false))\ + LSTRUCT2(lstruct2a,if(true),lstruct2a.store(pdr),lstruct2a.apply(pdr))\ + LSTRUCT2(lstruct2b,if(false),lstruct2b.store(pdr),lstruct2b.apply(pdr))\ + STRUCT_PTR_VECT(CMyPersistentClass_Struct,structPtrVect)\ + PROP_ARRAY(std::string,propArray,propArray.size())\ + STRUCT_ARRAY(structArray,structArray.size())\ + LFLAG(lflaga,if(true),nlinfo("lflag"))\ + LFLAG(lflagb,if(false),nlinfo("lflagb"))\ + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// basic test routines +//----------------------------------------------------------------------------- + +static void test1() +{ + CPersistentDataTree pdt; + pdt.readFromFile("pdrLines.txt"); + pdt.writeToFile("pdrLines_out1.txt"); + + CPersistentDataRecord pdr; + pdt.writeToPdr(pdr); + pdr.writeToFile("pdrLines_out.txt"); + pdr.writeToFile("pdrLines_out.xml"); + + CPersistentDataTree pdt2; + pdt2.readFromPdr(pdr); + pdt2.writeToFile("pdrLines_out2.txt"); + +} + +static void test2() +{ + NLMISC::CSheetId::init(false); + + CMyPersistentClass mpc0,mpc1; + CPersistentDataRecord pdr("TestTokenFamily"); + + // use a pdr record once + mpc0.store(pdr); + pdr.writeToTxtFile("test0a.xml"); + pdr.writeToBinFile("test0a.bin"); + + // reuse the same pdr record a second time + pdr.clear(); + mpc1.store(pdr); + pdr.writeToTxtFile("test1a.xml"); + pdr.writeToBinFile("test1a.bin"); +} + +static void test3() +{ + CMyPersistentClass mpc0,mpc1; + + // perform a swap + CPersistentDataRecord pdr0; + CPersistentDataRecord pdr1; + mpc0.store(pdr0); + mpc1.store(pdr1); + mpc1.apply(pdr0); + mpc0.apply(pdr1); + + // use a clean pair of records to store results + CPersistentDataRecord pdr2; + CPersistentDataRecord pdr3; + mpc0.store(pdr2); + mpc1.store(pdr3); + + pdr2.writeToTxtFile("test0c.xml"); + pdr3.writeToTxtFile("test1c.xml"); + + CPersistentDataRecord pdr4,pdr5; + pdr4.readFromBinFile("test0a.bin"); + CMyPersistentClass mpc4; + mpc4.apply(pdr4); + mpc4.store(pdr5); + pdr5.writeToTxtFile("test0d.xml"); + pdr5.writeToBinFile("test0d.bin"); + + CPersistentDataRecord pdr6; + pdr6.readFromTxtFile("test0a.xml"); + CMyPersistentClass mpc6; + mpc6.apply(pdr6); + pdr6.writeToTxtFile("test0e.xml"); + + CPersistentDataRecord pdr7a,pdr7b; + CMyPersistentClass3().store(pdr7a); + CMyPersistentClass2 mpc7; + mpc7.apply(pdr7a); + pdr7a.writeToTxtFile("test7a.xml"); + mpc7.store(pdr7b); + pdr7b.writeToTxtFile("test7b.xml"); + + CPersistentDataRecord pdr8a,pdr8b; + CMyPersistentClass4().store(pdr8a); + CMyPersistentClass2 mpc8; + mpc8.apply(pdr8a); + pdr8a.writeToTxtFile("test8a.xml"); + mpc8.store(pdr8b); + pdr8b.writeToTxtFile("test8b.xml"); + + CPersistentDataRecord pdr9a,pdr9b; + CMyPersistentClass5().store(pdr9a); + pdr9a.writeToTxtFile("test9a.xml"); + CMyPersistentClass6 mpc9; + mpc9.apply(pdr9a); + mpc9.store(pdr9b); + pdr9b.writeToTxtFile("test9b.xml"); + + CPersistentDataRecord pdr10a,pdr10b; + CMyPersistentClass7().store(pdr10a); + pdr10a.writeToTxtFile("test10a.xml"); + CMyPersistentClass7 mpc10a; + mpc10a.apply(pdr10a); + mpc10a.store(pdr10b); + pdr10b.writeToTxtFile("test10b.xml"); + CMyPersistentClass_Struct mpc10b; + pdr10a.rewind(); + mpc10b.apply(pdr10a); + + CPersistentDataRecord pdr11a, pdr11b, pdr11c; + CMyPersistentClass_Struct("abc","def").store(pdr11a); + pdr11a.writeToFile("test11a.bin"); + pdr11a.writeToFile("test11b.xml"); + pdr11a.writeToFile("test11c.bin"); + pdr11a.writeToFile("test11d.xml"); + pdr11b.readFromFile("test11a.bin"); + pdr11c.readFromFile("test11b.xml"); + NLMISC::InfoLog->displayNL("\nTest11:"); + std:: string s; + pdr11b.toString(s); + NLMISC::InfoLog->displayNL(s.c_str()); + pdr11c.toString(s); + NLMISC::InfoLog->displayNL(s.c_str()); +} + + +static void test4() +{ + CPersistentDataRecord pdr("TestTokenFamily"); + + // test 0 chars + CMyPersistentClass_Struct("","").store(pdr); + CMyPersistentClass_Struct("","").store(pdr); + + // test 1 char + CMyPersistentClass_Struct("A","B").store(pdr); + CMyPersistentClass_Struct("B","A").store(pdr); + + // test 2 chars + CMyPersistentClass_Struct("AA","BA").store(pdr); + CMyPersistentClass_Struct("BA","AA").store(pdr); + + // test 3 chars + CMyPersistentClass_Struct("AAA","BAA").store(pdr); + CMyPersistentClass_Struct("BAA","AAA").store(pdr); + CMyPersistentClass_Struct("AAB","BAB").store(pdr); + CMyPersistentClass_Struct("BAB","AAB").store(pdr); + + // test 4 chars + CMyPersistentClass_Struct("AAAA","BAAA").store(pdr); + CMyPersistentClass_Struct("BAAA","AAAA").store(pdr); + + // test 5 chars + CMyPersistentClass_Struct("AAAAA","BAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAA","AAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAB","BAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAB","AAAAB").store(pdr); + + // test 8 chars + CMyPersistentClass_Struct("AAAAAAAA","BAAAAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAAAAA","AAAAAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAAAAB","BAAAAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAAAAB","AAAAAAAB").store(pdr); + + // test 9 chars + CMyPersistentClass_Struct("AAAAAAAAA","BAAAAAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAAAAAA","AAAAAAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAAAAAB","BAAAAAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAAAAAB","AAAAAAAAB").store(pdr); + CMyPersistentClass_Struct("AAAABAAAB","BAAABAAAB").store(pdr); + CMyPersistentClass_Struct("BAAABAAAB","AAAABAAAB").store(pdr); + + // test 12 chars + CMyPersistentClass_Struct("AAAAxxxxAAAA","BAAAxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxAAAA","AAAAxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxAAAB","BAAAxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxAAAB","AAAAxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAYxxxAAAB","BAAAYxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAYxxxAAAB","AAAAYxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxxYAAAB","BAAAxxxYAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxYAAAB","AAAAxxxYAAAB").store(pdr); + + // test 13 chars + CMyPersistentClass_Struct("AAAAxxxxxAAAA","BAAAxxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxxAAAA","AAAAxxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxxAAAB","BAAAxxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxxAAAB","AAAAxxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAYxxxxAAAB","BAAAYxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAYxxxxAAAB","AAAAYxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxYAAAB","BAAAxxxxYAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxYAAAB","AAAAxxxxYAAAB").store(pdr); + + // test 16 chars + CMyPersistentClass_Struct("AAAAxxwwwwxxAAAA","BAAAxxwwwwxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxwwwwxxAAAA","AAAAxxwwwwxxAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAxxwwwwxxAAAB","BAAAxxwwwwxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxwwwwxxAAAB","AAAAxxwwwwxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAYxwwwwxxAAAB","BAAAYxwwwwxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAYxwwwwxxAAAB","AAAAYxwwwwxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxwwwwxYAAAB","BAAAxxwwwwxYAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxwwwwxYAAAB","AAAAxxwwwwxYAAAB").store(pdr); + + // test 17 chars + CMyPersistentClass_Struct("AAAAxxxxwxxxxAAAA","BAAAxxxxwxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxwxxxxAAAA","AAAAxxxxwxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxwxxxxAAAB","BAAAxxxxwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxwxxxxAAAB","AAAAxxxxwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAYxxxwxxxxAAAB","BAAAYxxxwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAYxxxwxxxxAAAB","AAAAYxxxwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxwxxxYAAAB","BAAAxxxxwxxxYAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxwxxxYAAAB","AAAAxxxxwxxxYAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxYxxxxAAAA","BAAAxxxxYxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxYxxxxAAAA","AAAAxxxxYxxxxAAAA").store(pdr); + + // test 20 chars + CMyPersistentClass_Struct("AAAAxxxxwwwwxxxxAAAA","BAAAxxxxwwwwxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxwwwwxxxxAAAA","AAAAxxxxwwwwxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxwwwwxxxxAAAB","BAAAxxxxwwwwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxwwwwxxxxAAAB","AAAAxxxxwwwwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAYxxxwwwwxxxxAAAB","BAAAYxxxwwwwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAYxxxwwwwxxxxAAAB","AAAAYxxxwwwwxxxxAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxwwwwxxxYAAAB","BAAAxxxxwwwwxxxYAAAB").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxwwwwxxxYAAAB","AAAAxxxxwwwwxxxYAAAB").store(pdr); + CMyPersistentClass_Struct("AAAAxxxxYwwwxxxxAAAA","BAAAxxxxYwwwxxxxAAAA").store(pdr); + CMyPersistentClass_Struct("BAAAxxxxYwwwxxxxAAAA","AAAAxxxxYwwwxxxxAAAA").store(pdr); + + pdr.writeToTxtFile("test0a.xml"); +} + +//----------------------------------------------------------------------------- +// class CIntTestObj +//----------------------------------------------------------------------------- + +class CIntTestObj +{ +public: + DECLARE_PERSISTENCE_METHODS + sint32 IntData; +}; + +#define PERSISTENT_CLASS CIntTestObj +#define PERSISTENT_DATA PROP(sint32,IntData) + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CStringTestObj +//----------------------------------------------------------------------------- + +class CStringTestObj +{ +public: + DECLARE_PERSISTENCE_METHODS + std::string StringData; +}; + +#define PERSISTENT_CLASS CStringTestObj +#define PERSISTENT_DATA PROP(std::string,StringData) + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CVectorTestObj +//----------------------------------------------------------------------------- + +class CVectorTestObj +{ +public: + DECLARE_PERSISTENCE_METHODS + std::vector VectorData; +}; + +#define PERSISTENT_CLASS CVectorTestObj +#define PERSISTENT_DATA PROP_VECT(sint32,VectorData) + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// class CMapTestObj +//----------------------------------------------------------------------------- + +class CMapTestObj +{ +public: + DECLARE_PERSISTENCE_METHODS + std::map MapData; +}; + +#define PERSISTENT_CLASS CMapTestObj +#define PERSISTENT_DATA PROP_MAP(sint32,sint32,MapData) + +#pragma message( PERSISTENT_GENERATION_MESSAGE ) +#include "game_share/persistent_data_template.h" + + +//----------------------------------------------------------------------------- +// speed test routines +//----------------------------------------------------------------------------- + +void miniSpeedTestA(CPersistentDataRecord& pdr,CIntTestObj& testObj); + +void miniSpeedTest() +{ + CPersistentDataRecord pdr("TestTokenFamily"); + CIntTestObj testObj; + miniSpeedTestA(pdr,testObj); +} + +void miniSpeedTestA(CPersistentDataRecord& pdr,CIntTestObj& testObj) +{ + testObj.store(pdr); +} + +static void speedTest1() +{ + // store the previous value of the Bench global and set Bench to true for the duration of our test + bool oldBench= NLMISC::CHTimer::benching(); + if (!oldBench) + NLMISC::CHTimer::startBench(false, true, false); + + // time the whole test + { + H_AUTO(PDRSpeedTest) + + // run the test 1000 times + for (uint32 i=0;i<1000;++i) + { + if ((i%100)==0) nlinfo("PDR Speed test: Benching iteration: %3i",i); + + // time each iteartion + H_AUTO(PDRSpeedIteration) + + // setup the pdr that we're going to store to + static CPersistentDataRecord pdr("TestTokenFamily"); + pdr.clear(); + + // int test + { + CIntTestObj testObj; + + H_AUTO(PDRSpeed_IntTest) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // string test1 (empty string) + { + CStringTestObj testObj; + + H_AUTO(PDRSpeed_StringTest1) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // string test2 (40 character long string - but always the same) + { + CStringTestObj testObj; + testObj.StringData= "This is a string of a reasonable length."; + + H_AUTO(PDRSpeed_StringTest2) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // string test3 (strings are always different) + { + H_AUTO(PDRSpeed_StringTest3) + + static char *words[]= { "This", "is", "a", "string", "bla", "of", "a", "reasonable", "length", "bla" }; + + CStringTestObj testObj[1000]; + { + H_AUTO(PDRSpeed_StringTest3Init) + for (uint32 j=0;j<1000;++j) + { + testObj[j].StringData= std::string()+ words[j%10]+" "+words[(j/10)%10]+" "+words[(j/100)%10]+" "+words[(j/1000)%10]; + } + } + + { + H_AUTO(PDRSpeed_StringTest3Body) + for (uint32 j=0;j<1000;++j) + { + testObj[j].store(pdr); + } + } + } + + // vector test1 (empty vector) + { + CVectorTestObj testObj; + + H_AUTO(PDRSpeed_VectorTest) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // vector test2 (vector with one element) + { + CVectorTestObj testObj; + testObj.VectorData.push_back(0); + + H_AUTO(PDRSpeed_VectorTest2) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // vector test3 (vector of 100 entries) + { + CVectorTestObj testObj; + + H_AUTO(PDRSpeed_VectorTest3) + { + H_AUTO(PDRSpeed_VectorTest3Init) + testObj.VectorData.resize(100); + for (sint32 j=0;j<100;++j) + { + testObj.VectorData.push_back(j); + } + } + { + H_AUTO(PDRSpeed_VectorTest3Body) + for (uint32 j=0;j<10;++j) + { + testObj.store(pdr); + } + } + } + + // map test1 (empty map) + { + CMapTestObj testObj; + + H_AUTO(PDRSpeed_MapTest) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // map test2 (map with one entry) + { + CMapTestObj testObj; + testObj.MapData[0]= 0; + + H_AUTO(PDRSpeed_MapTest) + for (uint32 j=0;j<1000;++j) + { + testObj.store(pdr); + } + } + + // map test3 (map with 100 entries) + { + CMapTestObj testObj; + + H_AUTO(PDRSpeed_MapTest3) + { + H_AUTO(PDRSpeed_MapTest3Init) + for (sint32 j=0;j<100;++j) + { + testObj.MapData[j]=j; + } + } + { + H_AUTO(PDRSpeed_MapTest3Body) + for (uint32 j=0;j<10;++j) + { + testObj.store(pdr); + } + } + } + + // store the pdr to a CMessage + { + static NLNET::CMessage* theMessage=NULL; + if (theMessage!=NULL) delete theMessage; + theMessage=new NLNET::CMessage; + + H_AUTO(PDRSpeed_WriteMessage) + pdr.toStream(*theMessage); + } + + #if 0 + // on the first run also store the result to different file types + if (i==0) + { + // store the pdr to a BIN file + { + H_AUTO(PDRSpeed_WriteBin) + pdr.writeToFile("pdr_speed_test_output.bin"); + } + + // store the pdr to a TXT file + { + H_AUTO(PDRSpeed_WriteTxt) + pdr.writeToFile("pdr_speed_test_output.txt"); + } + + // store the pdr to an XML file + { + H_AUTO(PDRSpeed_WriteXml) + pdr.writeToFile("pdr_speed_test_output.xml"); + } + } + #endif + } + } + + // restore previous value of the 'Bench' global + if (!oldBench) + NLMISC::CHTimer::endBench(); +} + +//----------------------------------------------------------------------------- +// class CPersistentDataTest +//----------------------------------------------------------------------------- + +class CPersistentDataTest: public IServiceSingleton +{ +public: + void init() + { + // test1(); // test pd tree & lines format + // test2(); // test a pdr containing a bit of everything + // test3(); + // test4(); // test different cases of addString + + //miniSpeedTest(); + speedTest1(); + } +}; + +static CPersistentDataTest PersistentDataTest; + diff --git a/code/ryzom/tools/server/test/r2_entry_point_test.cpp b/code/ryzom/tools/server/test/r2_entry_point_test.cpp new file mode 100644 index 000000000..68d1e7e3f --- /dev/null +++ b/code/ryzom/tools/server/test/r2_entry_point_test.cpp @@ -0,0 +1,75 @@ +/** \file r2_entry_point_test.cpp + * + * $id$ + * + */ + +#include +#include "nel/misc/types_nl.h" +#include "nel/misc/smart_ptr.h" +#include "nel/misc/hierarchical_timer.h" +#include "game_share/utils.h" +#include "game_share/timer.h" +#include "r2_share/scenario_entry_points.h" + +// #define ENABLE_TESTS +#include "game_share/sadge_tests.h" + +using namespace NLMISC; + +class CR2EntryPointTest: public IServiceSingleton +{ +public: + void test1(const CSString& packageDefinition) + { + // display a fancy title line + nlinfo("<------------------------------------------------------------------------------------------------------>"); + nlinfo("Displaying scenario entry points correspoding to package definition: '%s'",packageDefinition.c_str()); + + // get the vector of islands that we are allowed access to + CVectorSString islands; + R2::CScenarioEntryPoints::getInstance().getIslands(packageDefinition,islands); + + // run through the islands displaying them with their lists of entry points + for (uint32 i=0;i------------------------------------------------------------------------------------------------------<"); + } + + void init() + { + CPath::addSearchPath("./data_common/r2",1,0); + test1("j"); + test1("j1"); + test1("j2"); + test1("j1:j2"); + } + + void serviceUpdate() + { + } + +private: +}; + +static CR2EntryPointTest R2EntryPointTest; diff --git a/code/ryzom/tools/server/test/singleton_test.cpp b/code/ryzom/tools/server/test/singleton_test.cpp new file mode 100644 index 000000000..3b3443753 --- /dev/null +++ b/code/ryzom/tools/server/test/singleton_test.cpp @@ -0,0 +1,53 @@ +/* + Singleton test + + project: RYZOM / TEST + +*/ + +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" +#include "game_share/singleton_registry.h" + +class CSingletonTest: public IServiceSingleton +{ +public: + void init() + { + nlinfo("CSingletonTest::init()"); + serviceCounter=0; + tickCounter=0; + } + + void serviceUpdate() + { + ++serviceCounter; + if (serviceCounter>=50) + { + nlinfo("CSingletonTest::serviceUpdate() @50"); + serviceCounter=0; + } + } + + void tickUpdate() + { + ++tickCounter; + if (tickCounter>=25) + { + nlinfo("CSingletonTest::tickUpdate() @25"); + tickCounter=0; + } + } + + void release() + { + nlinfo("CSingletonTest::release()"); + } + +private: + uint32 tickCounter; + uint32 serviceCounter; +}; + +static CSingletonTest SingletonTest; diff --git a/code/ryzom/tools/server/test/sstring_test.cpp b/code/ryzom/tools/server/test/sstring_test.cpp new file mode 100644 index 000000000..0cd937d16 --- /dev/null +++ b/code/ryzom/tools/server/test/sstring_test.cpp @@ -0,0 +1,249 @@ +/* + SString test + + project: RYZOM / TEST +*/ + +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" +#include "game_share/singleton_registry.h" +#include "nel/misc/sstring.h" + +using namespace NLMISC; + +static void xmlTest(const NLMISC::CSString& s,bool isCompat,bool isCompatParam,bool isEncoded,const char* encode,const char* encodeParam,const char* decode) +{ + nlinfo("%s: isXMLCompat(f):%s isXMLCompat(t):%s isXMLCode:%s encode(f):%s encode(t):%s decode:%s",s.c_str(),s.isXMLCompatible()?"Y":"N",s.isXMLCompatible(true)?"Y":"N",s.isEncodedXML()?"Y":"N",s.encodeXML().c_str(),s.encodeXML(true).c_str(),s.decodeXML().c_str()); + nlassert(s.isXMLCompatible()==isCompat); + nlassert(s.isXMLCompatible(true)==isCompatParam); + nlassert(s.isEncodedXML()==isEncoded); + nlassert(s.encodeXML()==encode); + nlassert(s.encodeXML(true)==encodeParam); + nlassert(s.decodeXML()==decode); +} + +static void xmlTestSet() +{ + xmlTest("&hello&",false,false,false,"&hello&","&hello&","&hello&"); + xmlTest("&&",false,false,false,"&amp;&","&amp;&","&&"); + xmlTest("&",true,true,true,"&amp;","&amp;","&"); + xmlTest("&_",true,true,true,"&amp;_","&amp;_","&_"); + xmlTest("_&",true,true,true,"_&amp;","_&amp;","_&"); + xmlTest("_&_",true,true,true,"_&amp;_","_&amp;_","_&_"); + xmlTest(""",true,true,true,"&quot;","&quot;","\""); + xmlTest("<",true,true,true,"&lt;","&lt;","<"); + xmlTest(">",true,true,true,"&gt;","&gt;",">"); + xmlTest("<",false,false,false,"<","<","<"); + xmlTest(">",false,false,false,">",">",">"); + xmlTest("&",false,false,false,"&","&","&"); + xmlTest("\"",false,false,false,""",""","\""); + xmlTest("\t",true,false,false,"\t"," ","\t"); + xmlTest("\n",true,false,false,"\n"," ","\n"); + xmlTest("\r",true,false,false,"\r"," ","\r"); + xmlTest("\x9A",false,false,false,"š","š","\x9A"); + xmlTest("\xC3",false,false,false,"Ã","Ã","\xC3"); + xmlTest(" ",true,true,true,"&#x09;","&#x09;","\t"); + xmlTest("Z",true,true,true,"&#x5A;","&#x5A;","\x5A"); + xmlTest("¥",true,true,true,"&#xA5;","&#xA5;","\xA5"); + xmlTest("¥Z",true,true,true,"&#xA5;&#x5A;","&#xA5;&#x5A;","\xA5\x5A"); + xmlTest(" ",true,true,true,"&#xA;&#xD;","&#xA;&#xD;","\n\r"); +} + +static void quoteTest(const NLMISC::CSString& raw,const NLMISC::CSString& quoted) +{ + nlinfo("Testing quotes: %s",quoted.c_str()); + nlassert(raw.quote().unquote()==raw); + nlassert(quoted.unquote().quote()==quoted); + nlassert(quoted.quote().unquote()==quoted); + nlassert(raw.quote()==quoted); + nlassert(quoted.unquote()==raw); +} + +static void quoteTestSet() +{ + quoteTest("\"","\"\\\"\""); + quoteTest("\\","\"\\\\\""); + quoteTest("\a","\"\\a\""); + quoteTest("\b","\"\\b\""); + quoteTest("\f","\"\\f\""); + quoteTest("\n","\"\\n\""); + quoteTest("\r","\"\\r\""); + quoteTest("\t","\"\\t\""); + quoteTest("\v","\"\\v\""); + quoteTest("\x01","\"\\x01\""); + quoteTest("\xFE","\"\\xFE\""); + quoteTest("\xef","\"\\xef\""); +} + +static void splitWordsTest(const NLMISC::CSString& pre,char separator,const NLMISC::CSString& post) +{ + nlinfo("Testing split: %s",pre.c_str()); + + NLMISC::CVectorSString words; + pre.splitWords(words); + + NLMISC::CSString joined; + joined.join(words,separator); + nlassert(joined==post); + + joined.clear(); + joined.join(words,NLMISC::CSString(separator)); + nlassert(joined==post); +} + +static void splitJoinTestSet() +{ + splitWordsTest("bob bub",',',"bob,bub"); + splitWordsTest("\t bob\t bub\t ",',',"bob,bub"); + splitWordsTest("\t +bob\t -bub\t ",',',"+,bob,-,bub"); +} + +static void splitToLineCommentTest(const NLMISC::CSString& pre, const NLMISC::CSString& post) +{ + CSString s= pre; + + // make sure post matches result of split + nlassert(post==s.splitToLineComment()); + // make sure split is non destructive + nlassert(s==pre); + + // try splitting destructively + CSString s2= s.splitToLineComment(true); + nlassert((s2+s)==pre); +} + +static void splitToLineCommentTest2(const NLMISC::CSString& pre, const NLMISC::CSString& postWithEscape, const NLMISC::CSString& postWithoutEscape) +{ + CSString s= pre; + + // make sure post matches result of split + nlassert(postWithEscape==s.splitToLineComment(false,true)); + // make sure split is non destructive + nlassert(s==pre); + + // make sure post matches result of split + nlassert(postWithoutEscape==s.splitToLineComment(false,false)); + // make sure split is non destructive + nlassert(s==pre); +} + +static void splitToLineCommentTestSet() +{ + // some basic strings with no comments + splitToLineCommentTest("a","a"); + splitToLineCommentTest(" a "," a "); + splitToLineCommentTest("\"\"","\"\""); + splitToLineCommentTest(" \" \" "," \" \" "); + splitToLineCommentTest("\"a","\"a"); + splitToLineCommentTest(" \" a "," \" a "); + splitToLineCommentTest("a\"","a\""); + splitToLineCommentTest(" a \" "," a \" "); + splitToLineCommentTest("/","/"); + splitToLineCommentTest("/ /","/ /"); + splitToLineCommentTest(" / "," / "); + splitToLineCommentTest("/ ","/ "); + splitToLineCommentTest(" /"," /"); + + // some basic cases with a comment + splitToLineCommentTest("//",""); + splitToLineCommentTest("a//","a"); + splitToLineCommentTest("//a",""); + splitToLineCommentTest("a//b","a"); + splitToLineCommentTest("\"a\"//b","\"a\""); + splitToLineCommentTest("a//\"b\"","a"); + + // some basic cases with a '//' in a string (no comment) + splitToLineCommentTest("\"//\"","\"//\""); + splitToLineCommentTest(" \" // \" "," \" // \" "); + splitToLineCommentTest("\" // a \"","\" // a \""); + + // some cases with a bit of everything + splitToLineCommentTest("a\"//b\"//c","a\"//b\""); + splitToLineCommentTest(" a \" // b \" // c "," a \" // b \" "); + splitToLineCommentTest("\" // a \" b // c ","\" // a \" b "); + + // test some simeple escape cases + splitToLineCommentTest2("\\", "\\", "\\" ); + splitToLineCommentTest2("a\\bc", "a\\bc", "a\\bc" ); + splitToLineCommentTest2("\\/", "\\/", "\\/" ); + splitToLineCommentTest2("\\//", "\\//", "\\" ); + splitToLineCommentTest2("\\///", "\\/", "\\" ); + splitToLineCommentTest2("\"//\"", "\"//\"", "\"//\"" ); + splitToLineCommentTest2("\\\"//\"//", "\\\"", "\\\"//\"" ); + splitToLineCommentTest2("\"\\//\"//", "\"\\//\"", "\"\\//\"" ); + splitToLineCommentTest2("\"//\\\"//", "\"//\\\"//", "\"//\\\"" ); + splitToLineCommentTest2("\"//\"\\//", "\"//\"\\//", "\"//\"\\" ); + splitToLineCommentTest2("\"//\"//\\", "\"//\"", "\"//\"" ); +} + +static void atoiTest() +{ + // atosi - valid values + nlassert(NLMISC::CSString("-2147483648").atosi()==-(int)0x80000000u); + nlassert(NLMISC::CSString("-1").atosi()==-1); + nlassert(NLMISC::CSString("0").atosi()==0); + nlassert(NLMISC::CSString("1").atosi()==1); + nlassert(NLMISC::CSString("2147483647").atosi()==0x7FFFFFFF); + nlassert(NLMISC::CSString("+2147483647").atosi()==0x7FFFFFFF); + + // atosi - invalid values + nlassert(NLMISC::CSString("-2147483649").atosi()==0); + nlassert(NLMISC::CSString("2147483648").atosi()==0); + nlassert(NLMISC::CSString("123abc").atosi()==0); + nlassert(NLMISC::CSString("++1").atosi()==0); + nlassert(NLMISC::CSString("--1").atosi()==0); + nlassert(NLMISC::CSString("").atosi()==0); + + // atoui - valid values + nlassert(NLMISC::CSString("0").atoui()==0); + nlassert(NLMISC::CSString("1").atoui()==1); + nlassert(NLMISC::CSString("2147483648").atoui()==0x80000000u); + nlassert(NLMISC::CSString("4294967295").atoui()==0xFFFFFFFFu); + + // atoui - invalid values + nlassert(NLMISC::CSString("").atoui()==0); + nlassert(NLMISC::CSString("-1").atoui()==0); + nlassert(NLMISC::CSString("+1").atoui()==0); + nlassert(NLMISC::CSString("4294967296").atoui()==0); +} + +static void loadAndSaveTest() +{ + const char* normalFile= "string_test.tmp"; + const char* lockedFile= "a/b/c/d/non_existent_directory/string_test_locked.tmp"; + + // test a normal case - write text to a file and read it back... + NLMISC::CSString s0="hello world"; + NLMISC::CSString s1="moby"; + bool r0=s0.writeToFile(normalFile); + nlassert(r0); + bool r1=s1.readFromFile(normalFile); + nlassert(r1); + nlassert(s0==s1); + + // test a case with an inaccessible file... + NLMISC::CSString s2="bye bye blackbird"; + NLMISC::CSString s3="mop mop"; + bool r2=s2.writeToFile(lockedFile); + nlassert(!r2); + bool r3=s3.readFromFile(lockedFile); + nlassert(!r3); + nlassert(s3.empty()); +} + +class CSStringTest: public IServiceSingleton +{ +public: + void init() + { + xmlTestSet(); + quoteTestSet(); + splitJoinTestSet(); + splitToLineCommentTestSet(); + atoiTest(); + loadAndSaveTest(); + } +}; + +static CSStringTest Test; diff --git a/code/ryzom/tools/server/test/test.cpp b/code/ryzom/tools/server/test/test.cpp new file mode 100644 index 000000000..15900bade --- /dev/null +++ b/code/ryzom/tools/server/test/test.cpp @@ -0,0 +1,69 @@ +/** \file tick_service.cpp + * The TICK SERVICE deals with time management in the shard + * + * $Id: test.cpp,v 1.4 2005/04/25 23:55:00 miller Exp $ + */ + + + +#include "nel/misc/command.h" +#include "nel/misc/variable.h" +#include "nel/misc/common.h" +#include "nel/misc/file.h" + +#include "game_share/ryzom_version.h" +#include "game_share/tick_event_handler.h" +#include "game_share/singleton_registry.h" +#include "game_share/handy_commands.h" + +#include "test.h" + +using namespace std; +using namespace NLMISC; +using namespace NLNET; + + +/* + * Initialise the service + */ +void CTest::init() +{ + setVersion (RYZOM_VERSION); + + // if we are connecting to a shard then start by initializing the tick interface + if (IService::getInstance()->ConfigFile.getVarPtr("DontUseTS")==NULL || IService::getInstance()->ConfigFile.getVarPtr("DontUseTS")->asInt()==0) + CTickEventHandler::init(CTest::tickUpdate); + + CSingletonRegistry::getInstance()->init(); +} + +/* + * Update + */ +bool CTest::update() +{ + CSingletonRegistry::getInstance()->serviceUpdate(); + return true; +} + +/* + * Update + */ +void CTest::tickUpdate() +{ + CSingletonRegistry::getInstance()->tickUpdate(); +} + +/* + * Release + */ +void CTest::release() +{ + CSingletonRegistry::getInstance()->release(); +} + +//----------------------------------------------- +// NLNET_SERVICE_MAIN +//----------------------------------------------- +NLNET_SERVICE_MAIN( CTest, "TEST", "test_service", 0, EmptyCallbackArray, "", "" ); + diff --git a/code/ryzom/tools/server/test/test.h b/code/ryzom/tools/server/test/test.h new file mode 100644 index 000000000..9bb25b32a --- /dev/null +++ b/code/ryzom/tools/server/test/test.h @@ -0,0 +1,42 @@ +/** \file tick_service.h + * The TICK SERVICE deals with time management in the shard + * + * $Id: test.h,v 1.1 2004/06/07 15:26:49 miller Exp $ + */ + +#ifndef TEST_H +#define TEST_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/time_nl.h" +#include "nel/misc/common.h" + +#include "nel/net/service.h" + +/** + * CTest + * + * \author Stephane Coutelas + * \author Nevrax France + * \date 2001 + */ +class CTest : public NLNET::IService +{ +public : + + /// Initialise the service + void init(); + + /// Update + bool update(); + + /// Tick Update + static void tickUpdate(); + + /// Release + void release(); + +}; + + +#endif //TICK_S_H diff --git a/code/ryzom/tools/server/test/timer_test.cpp b/code/ryzom/tools/server/test/timer_test.cpp new file mode 100644 index 000000000..df6445a28 --- /dev/null +++ b/code/ryzom/tools/server/test/timer_test.cpp @@ -0,0 +1,32 @@ +/* + Timer test + + project: RYZOM / TEST +*/ + +#include "game_share/timer.h" + +class CTimerTest: public IServiceSingleton +{ +public: + class CTimerTestTimerEvent:public CTimerEvent + { + public: + void timerCallback(CTimer* owner) + { + nlinfo("tick!"); + // repeat every 20 ticks + owner->setRemaining(20,this); + } + }; + + void init() + { + _Timer.setRemaining(20,new CTimerTestTimerEvent); + } + +private: + CTimer _Timer; +}; + +static CTimerTest Test; diff --git a/code/ryzom/tools/server/test/utils_test.cpp b/code/ryzom/tools/server/test/utils_test.cpp new file mode 100644 index 000000000..e6891551f --- /dev/null +++ b/code/ryzom/tools/server/test/utils_test.cpp @@ -0,0 +1,115 @@ +/* + Utils test + + project: RYZOM / TEST + +*/ + +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" + +#include "game_share/singleton_registry.h" +#include "game_share/utils.h" + +void traceTest2(int i) +{ + CSTRACE; + if (i<2) + traceTest2(++i); + else + SHOW_CALLSTACK; +} + +void traceTest() +{ + CSTRACE_MSG("foo"); + traceTest2(0); + { + int i=0; + CSTRACE_VAR(int,i); + CSTRACE_VAL(int,i); + i=1; + SHOW_CALLSTACK; + } + WARN_CALLSTACK; +} + +class CUtilsTest: public IServiceSingleton +{ +public: + void init() + { + // nel info, warning and debug redirectrion tests + nldebug("debug"); nlinfo("info"); nlwarning("warning"); + { + CNLLogOverride hold(NLMISC::DebugLog); + nldebug("debug"); nlinfo("info"); nlwarning("warning"); + } + { + CNLLogOverride hold(NLMISC::InfoLog); + nldebug("debug"); nlinfo("info"); nlwarning("warning"); + } + { + CNLLogOverride hold(NLMISC::WarningLog); + nldebug("debug"); nlinfo("info"); nlwarning("warning"); + } + nldebug("debug"); nlinfo("info"); nlwarning("warning"); + + + // handy vector method tests + std::vector vect; + + vectAppend(vect)= 0; nlassert(vect.size()==1); nlassert(vect[0]==0); + vectAppend(vect)= 1; nlassert(vect.size()==2); nlassert(vect[1]==1); + vectAppend(vect)= 2; nlassert(vect.size()==3); nlassert(vect[2]==2); + + vectInsert(vect,2); nlassert(vect.size()==3); nlassert(vect[0]+vect[1]+vect[2]==3); + vectInsert(vect,4); nlassert(vect.size()==4); nlassert(vect[3]==4); + + // handy ptr class tests + CTestClass tc; + + CTestClass* tcptr= &tc; + CTestClass& tcref= tc; + IPtr ptr; + ptr= tcptr; + ptr= &tc; + ptr= &tcref; + ++ptr; + --ptr; + tcptr= ptr.operator->(); + tcref= *ptr; + nlassert(ptr==ptr); + nlassert(!(ptr!=ptr)); + nlassert(ptr==tcptr); + nlassert(!(ptr!=tcptr)); + + CTestClass const* ctcptr= &tc; + CTestClass const& ctcref= tc; + IConstPtr cptr; + cptr= ctcptr; + cptr= &tc; + cptr= &ctcref; + ++cptr; + --cptr; + ctcptr= cptr.operator->(); +// ctcref= *cptr; + nlassert(cptr==cptr); + nlassert(!(cptr!=cptr)); + nlassert(cptr==ctcptr); + nlassert(!(cptr!=ctcptr)); + + // trace system test + traceTest(); + } + + class CTestClass + { + public: + int a,b; + }; +}; + +static CUtilsTest UtilsTest; + diff --git a/code/ryzom/tools/server/test/utils_test_asserts.cpp b/code/ryzom/tools/server/test/utils_test_asserts.cpp new file mode 100644 index 000000000..175003e9e --- /dev/null +++ b/code/ryzom/tools/server/test/utils_test_asserts.cpp @@ -0,0 +1,48 @@ +/* + Utils tests - macros that assert or break execution + + project: RYZOM / TEST + +*/ + +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" + +#include "game_share/singleton_registry.h" +#include "game_share/utils.h" + +static class CUtilsAssertTest: public IServiceSingleton +{ +public: + void init() + { + // warning system tests + WARN("WARN"); + STOP("STOP"); + BOMB("BOMB",nldebug("BOMB action")); + WARN_IF(true,"WARN_IF"); + STOP_IF(true,"STOP_IF"); + BOMB_IF(true,"BOMB_IF",nldebug("BOMB_IF action")); + + // this should fail in debug but not in release + nlassertd(false); + + // testing the onChange macros + int i=0; + { + ON_CHANGE_ASSERT(int,i); + { + ++i; + ON_CHANGE_ASSERT(int,i); + // this should drop through fine + } + // there should be an assert here + nldebug("There should be an assert after this message"); + } + nldebug("There should be an assert before this message"); + + } + +} +Test; diff --git a/code/ryzom/tools/server/test_modules/egs_test/egs_place_holder.h b/code/ryzom/tools/server/test_modules/egs_test/egs_place_holder.h new file mode 100644 index 000000000..a3c2797ae --- /dev/null +++ b/code/ryzom/tools/server/test_modules/egs_test/egs_place_holder.h @@ -0,0 +1,160 @@ + + +#ifndef EGS_PLACE_HOLDER_H +#define EGS_PLACE_HOLDER_H + +#include "nel/misc/smart_ptr.h" +#include "nel/misc/enum_bitset.h" +#include "nel/misc/sheet_id.h" +#include "nel/net/cvar_log_filter.h" +#include "game_share/skills.h" +#include "game_share/characteristics.h" +#include "game_share/type_skill_mod.h" +#include "game_share/item_family.h" +#include "game_share/item_type.h" +#include "game_share/inventories.h" +#include "entities_game_service/game_item_manager/weapon_craft_parameters.h" +#include "entities_game_service/weapon_damage_table.h" + +NL_DECLARE_CVAR_INFO_LOG_FUNCTION(egs_giinfo, GameItemLogEnabled, true) + +class CGameItemPtr; + +class CInventoryBase : public NLMISC::CRefCount +{ +public: + enum // for pseudo constantes + { + INSERT_IN_FIRST_FREE_SLOT = 0xFFFFFFFF, + REMOVE_MAX_STACK_QUANTITY = 0xFFFFFFFF, + INVALID_INVENTORY_SLOT = INSERT_IN_FIRST_FREE_SLOT, + }; + + enum TItemChange + { + itc_bulk = 1<<0, + itc_weight = 1<<1, + itc_enchant = 1<<2, + itc_hp = 1<<3, + itc_inserted = 1<<4, + itc_removed = 1<<5, + itc_lock_state = 1<<6, + itc_info_version = 1<<7, + itc_worned = 1<<8, + }; + + enum TInventoryOpResult + { + ior_overbulk, + }; + + + typedef NLMISC::CEnumBitset TItemChangeFlags; + + uint getSlotCount() {return 0;}; + + virtual void onItemStackSizeChanged(uint32 slot, uint32 previousStackSize) {} + virtual void onItemChanged(uint32 slot, CInventoryBase::TItemChangeFlags changeFlags) {} + + virtual CGameItemPtr removeItem(uint32 slot, uint32 quantity = REMOVE_MAX_STACK_QUANTITY, TInventoryOpResult * res = NULL); + + virtual TInventoryOpResult insertItem(CGameItemPtr &item, uint32 slot = INSERT_IN_FIRST_FREE_SLOT, bool autoStack = false) { return ior_overbulk;} + +}; + +typedef NLMISC::CSmartPtr CInventoryPtr; + +namespace ITEM_WORN_STATE +{ + enum TItemWornState + { + Unspoiled = 0, + WornState1, + WornState2, + WornState3, + WornState4, + Worned, + }; +} + +class CPlayerManager +{ +}; + +struct CMP +{ + uint16 StatEnergy; // 0..100 + +}; + +class CStaticBrick +{ +}; + +class CStaticItem +{ +public: + float getBaseWeight() const; + + std::string Name; + uint32 Weight; + uint32 Bulk; + + NLMISC::CSheetId CraftPlan; + SKILLS::ESkills RequiredSkill; + SKILLS::ESkills RequiredSkill2; + CHARACTERISTICS::TCharacteristics RequiredCharac; + std::vector TypeSkillMods; + float RequiredSkillQualityFactor; + sint16 RequiredSkillQualityOffset; + uint16 MinRequiredSkillLevel; + float RequiredSkillQualityFactor2; + sint16 RequiredSkillQualityOffset2; + uint16 MinRequiredSkillLevel2; + float RequiredCharacQualityFactor; + sint16 RequiredCharacQualityOffset; + uint16 MinRequiredCharacLevel; + uint32 Stackable; + ITEMFAMILY::EItemFamily Family; + CMP * Mp; + ITEM_TYPE::TItemType Type; + +}; + +class CSheets +{ +public: + static CStaticItem *getForm(const NLMISC::CSheetId &sheet) {return NULL;}; + static const CStaticBrick* getSBrickForm( const NLMISC::CSheetId& sheetId ); +}; +//NL_DECLARE_CVAR_INFO_LOG_FUNCTION(egs_giinfo, GameItemLogEnabled, true) + +extern NLMISC::CVariable WornState1; +extern NLMISC::CVariable WornState2; +extern NLMISC::CVariable WornState3; +extern NLMISC::CVariable WornState4; + +class CGameItemManager +{ +public: +}; + + +extern CGameItemManager GameItemManager; + +class CCharacter +{ +public: + inline const TDataSetRow& getEntityRowId() const + { + static TDataSetRow foo; + + return foo; + } + + const CInventoryPtr &getInventory(INVENTORIES::TInventory id) const; +}; + + + +#endif \ No newline at end of file diff --git a/code/ryzom/tools/server/test_modules/game_share_test/game_share_test.cpp b/code/ryzom/tools/server/test_modules/game_share_test/game_share_test.cpp new file mode 100644 index 000000000..b75895587 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/game_share_test/game_share_test.cpp @@ -0,0 +1,45 @@ + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/dynloadlib.h" +#include "src/cpptest.h" + +using namespace std; + +Test::Suite *createPrimitiveObjectTS(const std::string &workingPath); +Test::Suite *createModuleInterfaceTS(); + + +// global test for any game share feature +class CGameShareTS : public Test::Suite +{ +public: + CGameShareTS(const std::string &workingPath) + { + add(auto_ptr(createPrimitiveObjectTS(workingPath))); + add(auto_ptr(createModuleInterfaceTS())); + + // initialise the application context + NLMISC::CApplicationContext::getInstance(); + + NLMISC::createDebug(); + } + +private: +}; + +// +//// register the misc test suite +//void registerNelMiscTestSuite(Test::Suite &mainTestSuite) +//{ +// mainTestSuite.add(auto_ptr(new CMiscTestSuite)); +//} + + +auto_ptr intRegisterTestSuite(const std::string &workingPath) +{ + return static_cast(new CGameShareTS(workingPath)); +} + +NL_LIB_EXPORT_SYMBOL(registerTestSuite, void, intRegisterTestSuite); + diff --git a/code/ryzom/tools/server/test_modules/game_share_test/prim_object_test.cpp b/code/ryzom/tools/server/test_modules/game_share_test/prim_object_test.cpp new file mode 100644 index 000000000..d2ce6fe5d --- /dev/null +++ b/code/ryzom/tools/server/test_modules/game_share_test/prim_object_test.cpp @@ -0,0 +1,1007 @@ + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/dynloadlib.h" +#include "nel/misc/path.h" +#include "nel/net/service.h" +#include "nel/ligo/ligo_config.h" +#include "src/cpptest.h" +#include "game_share/primitive_object.h" + +#include + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace NLLIGO; + +// define some object to be linked with the primitive tree + +class CCounterBase : public IPrimitiveObject +{ +public: + CCounterBase(const std::string &primitiveFileName, TAIAlias alias) + : IPrimitiveObject(primitiveFileName, alias) + { + PreUpdateCount = 0; + UpdateCount = 0; + PostUpdateCount = 0; + PreDeleteCount = 0; + PreDeleteObjectCount = 0; + } + + virtual void onPreUpdatePrimitiveFile() + { + ++PreUpdateCount; + } + + virtual void onUpdatePrimObject(NLLIGO::IPrimitive *prim, bool firstTime) + { + if (!prim->getPropertyByName("name", Name)) + throw "Can't read property 'name'"; + if (!prim->getPropertyByName("value", Value)) + throw "Can't read property 'value'"; + if (!((firstTime && UpdateCount == 0) || (!firstTime && UpdateCount > 0))) + throw "Invalid 'firstTime' flag"; + + ++UpdateCount; + } + + virtual void onPostUpdatePrimitiveFile() + { + ++PostUpdateCount; + } + + virtual void onPreDeleteObjects(const std::set &objectsList) + { + ++PreDeleteCount; + PreDeleteObjectCount += objectsList.size(); + } + + string Name; + string Value; + uint PreUpdateCount; + uint UpdateCount; + uint PostUpdateCount; + uint PreDeleteCount; + uint PreDeleteObjectCount; +}; + +// Type 1 object ========================================= +class CType1 : public CCounterBase +{ + NL_INSTANCE_COUNTER_DECL(CType1); +public: + CType1(const std::string &primitiveFileName, TAIAlias alias) + : CCounterBase(primitiveFileName, alias) + { + nlinfo("Created CType1 \t@%p", this); + ObjectIndex = Type1Objects.size(); + Type1Objects.push_back(this); + } + + ~CType1() + { + nlinfo("Deleted CType1 \t@%p", this); + Type1Objects[ObjectIndex] = NULL; + } + + + virtual class IPrimitiveObjectDescriptor *getDescriptor(); + + int ObjectIndex; + static vector Type1Objects; +}; +NL_INSTANCE_COUNTER_IMPL(CType1); +vector CType1::Type1Objects; + +class CType1Descriptor : public IPrimitiveObjectDescriptor +{ +public: + CType1Descriptor() : IPrimitiveObjectDescriptor("type1") {} + + virtual IPrimitiveObject *create(const std::string &fileName, TAIAlias alias) + { + return new CType1(fileName, alias); + } + +}; + +CType1Descriptor type1Descriptor; + +IPrimitiveObjectDescriptor *CType1::getDescriptor() +{ + return &type1Descriptor; +} + + +// Type 2 mode 1 object ========================================= +class CType2Mode1 : public CCounterBase +{ + NL_INSTANCE_COUNTER_DECL(CType2Mode1); +public: + CType2Mode1(const std::string &primitiveFileName, TAIAlias alias) + : CCounterBase(primitiveFileName, alias) + { + nlinfo("Created CType2Mode1 \t@%p", this); + ObjectIndex = Type2Mode1Objects.size(); + Type2Mode1Objects.push_back(this); + } + + ~CType2Mode1() + { + nlinfo("Deleted CType2Mode1 \t@%p", this); + Type2Mode1Objects[ObjectIndex] = NULL; + } + + virtual class IPrimitiveObjectDescriptor *getDescriptor(); + + int ObjectIndex; + static vector Type2Mode1Objects; +}; +NL_INSTANCE_COUNTER_IMPL(CType2Mode1); +vector CType2Mode1::Type2Mode1Objects; + +class CType2Mode1Descriptor : public IPrimitiveObjectDescriptor +{ +public: + CType2Mode1Descriptor() : IPrimitiveObjectDescriptor("type2") {} + + virtual IPrimitiveObject *create(const std::string &fileName, TAIAlias alias) + { + return new CType2Mode1(fileName, alias); + } + + bool additionnalFilter(NLLIGO::IPrimitive *prim) + { + string mode; + prim->getPropertyByName("mode", mode); + if (mode == "mode1") + return true; + + return false; + } + +}; + +CType2Mode1Descriptor type2Mode1Descriptor; + + + +IPrimitiveObjectDescriptor *CType2Mode1::getDescriptor() +{ + return &type2Mode1Descriptor; +} + +// Type 2 mode 2 object ========================================= +class CType2Mode2 : public CCounterBase +{ + NL_INSTANCE_COUNTER_DECL(CType2Mode2); +public: + CType2Mode2(const std::string &primitiveFileName, TAIAlias alias) + : CCounterBase(primitiveFileName, alias) + { + nlinfo("Created CType2Mode2 \t@%p", this); + ObjectIndex = Type2Mode2Objects.size(); + Type2Mode2Objects.push_back(this); + } + + ~CType2Mode2() + { + nlinfo("Deleted CType2Mode2 \t@%p", this); + Type2Mode2Objects[ObjectIndex] = NULL; + } + + + virtual class IPrimitiveObjectDescriptor *getDescriptor(); + + int ObjectIndex; + static vector Type2Mode2Objects; +}; +NL_INSTANCE_COUNTER_IMPL(CType2Mode2); +vector CType2Mode2::Type2Mode2Objects; + +class CType2Mode2Descriptor : public IPrimitiveObjectDescriptor +{ +public: + CType2Mode2Descriptor() : IPrimitiveObjectDescriptor("type2") {} + + virtual IPrimitiveObject *create(const std::string &fileName, TAIAlias alias) + { + return new CType2Mode2(fileName, alias); + } + + bool additionnalFilter(NLLIGO::IPrimitive *prim) + { + string mode; + prim->getPropertyByName("mode", mode); + if (mode == "mode2") + return true; + + return false; + } +}; + +CType2Mode2Descriptor type2Mode2Descriptor; + + + +IPrimitiveObjectDescriptor *CType2Mode2::getDescriptor() +{ + return &type2Mode2Descriptor; +} + +// Type 3 object ========================================= +class CType3 : public CCounterBase +{ + NL_INSTANCE_COUNTER_DECL(CType3); +public: + CType3(const std::string &primitiveFileName, TAIAlias alias) + : CCounterBase(primitiveFileName, alias) + { + nlinfo("Created CType3 \t@%p", this); + ObjectIndex = Type3Objects.size(); + Type3Objects.push_back(this); + } + + ~CType3() + { + nlinfo("Deleted CType3 \t@%p", this); + Type3Objects[ObjectIndex] = NULL; + } + + + virtual class IPrimitiveObjectDescriptor *getDescriptor(); + + int ObjectIndex; + static vector Type3Objects; +}; +NL_INSTANCE_COUNTER_IMPL(CType3); +vector CType3::Type3Objects; + +class CType3Descriptor : public IPrimitiveObjectDescriptor +{ +public: + CType3Descriptor() : IPrimitiveObjectDescriptor("poly_type") {} + + virtual IPrimitiveObject *create(const std::string &fileName, TAIAlias alias) + { + return new CType3(fileName, alias); + } + +}; + +CType3Descriptor type3Descriptor; + + + +IPrimitiveObjectDescriptor *CType3::getDescriptor() +{ + return &type3Descriptor; +} + +// Type 3 object ========================================= +class CType4 : public CCounterBase +{ + NL_INSTANCE_COUNTER_DECL(CType4); +public: + CType4(const std::string &primitiveFileName, TAIAlias alias) + : CCounterBase(primitiveFileName, alias) + { + nlinfo("Created CType4 \t@%p", this); + ObjectIndex = Type4Objects.size(); + Type4Objects.push_back(this); + } + + ~CType4() + { + nlinfo("Deleted CType4 \t@%p", this); + Type4Objects[ObjectIndex] = NULL; + } + + + virtual class IPrimitiveObjectDescriptor *getDescriptor(); + + int ObjectIndex; + static vector Type4Objects; +}; +NL_INSTANCE_COUNTER_IMPL(CType4); +vector CType4::Type4Objects; + +class CType4Descriptor : public IPrimitiveObjectDescriptor +{ +public: + CType4Descriptor() : IPrimitiveObjectDescriptor("poly_type") {} + + virtual IPrimitiveObject *create(const std::string &fileName, TAIAlias alias) + { + return new CType4(fileName, alias); + } + +}; + +CType4Descriptor type4Descriptor; + + + +IPrimitiveObjectDescriptor *CType4::getDescriptor() +{ + return &type4Descriptor; +} + +// fake service class ========================================= + +class CFakeService : public IService +{ + +}; + +class CPrimitiveObjectTS: public Test::Suite +{ + string _WorkingPath; + string _BaseDir; + string _CurrentPath; + string _CurrentPathToRestore; + + CFakeService *_TheService; + +public: + CPrimitiveObjectTS(const std::string &workingPath) + { + _WorkingPath = workingPath; + TEST_ADD(CPrimitiveObjectTS::initialLoading) + TEST_ADD(CPrimitiveObjectTS::changedContent) + TEST_ADD(CPrimitiveObjectTS::addedPrimitive) + TEST_ADD(CPrimitiveObjectTS::removedContent) + TEST_ADD(CPrimitiveObjectTS::removedPrimitive) + TEST_ADD(CPrimitiveObjectTS::mutiObject) + TEST_ADD(CPrimitiveObjectTS::fullCleanup) + } + + void setup() + { + _TheService = new CFakeService(); +// _BaseDir = _WorkingPath+"/test_files"; + _BaseDir = "test_files"; +// _CurrentPath = "R:/cvs_rework/code/ryzom/test_files/game_share_test"; + _CurrentPath = _BaseDir+"/game_share_test"; + + // Set default directory + _CurrentPathToRestore = CPath::getCurrentPath(); + CPath::setCurrentPath(_CurrentPath.c_str()); + + _TheService->setArgs("prim_object_test -Zu"); +// _TheService.main("POT", "prim_object_test", 0, _CurrentPath.c_str(), _CurrentPath.c_str(), __DATE__" "__TIME__); + _TheService->main("POT", "prim_object_test", 0, _WorkingPath.c_str(), _WorkingPath.c_str(), __DATE__" "__TIME__); + + // register ligo class factory + static bool registered = false; + if (!registered) + { + NLLIGO::Register(); + registered = true; + } + + // init ligo + CPrimitiveLoader::getInstance()->initLigoConfig("ligo_class.xml"); + + } + void tear_down() + { + delete _TheService; + // Restore default path + CPath::setCurrentPath(_CurrentPathToRestore.c_str()); + } + + // Build the files content for the current step + void installStepFiles(const std::string &prefix) + { + // cleanup the tmp directory + vector files; +// CPath::getPathContent(_BaseDir+"/tmp", true, false, true, files); + CPath::getPathContent("../tmp", true, false, true, files); + while (!files.empty()) + { + if (!CFile::deleteFile(files.back())) + throw "Can not delete temp file !"; + files.pop_back(); + } + + CPath::getPathContent(".", false, false, true, files); + + for (uint i=0; iupdatePrimitives(); + + // Do varius check on created object & counters + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 3); + TEST_ASSERT(CType1::Type1Objects.size() == 3); + + TEST_ASSERT(CType1::Type1Objects[0]->PreUpdateCount == 0); + TEST_ASSERT(CType1::Type1Objects[0]->UpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[0]->PostUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[0]->PreDeleteCount== 0); + TEST_ASSERT(CType1::Type1Objects[0]->Name == "object1_type1"); + TEST_ASSERT(CType1::Type1Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[0]->PreDeleteObjectCount == 0); + + TEST_ASSERT(CType1::Type1Objects[1]->PreUpdateCount == 0); + TEST_ASSERT(CType1::Type1Objects[1]->UpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[1]->PostUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteCount== 0); + TEST_ASSERT(CType1::Type1Objects[1]->Name == "object2_type1"); + TEST_ASSERT(CType1::Type1Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteObjectCount == 0); + + TEST_ASSERT(CType1::Type1Objects[2]->PreUpdateCount == 0); + TEST_ASSERT(CType1::Type1Objects[2]->UpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[2]->PostUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteCount== 0); + TEST_ASSERT(CType1::Type1Objects[2]->Name == "object3_type1"); + TEST_ASSERT(CType1::Type1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteObjectCount == 0); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 1); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->PreUpdateCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->UpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->PostUpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->Name == "object4_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0]->PreDeleteObjectCount == 0); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 1); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 1); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->PreUpdateCount == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->UpdateCount == 1); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->PostUpdateCount == 1); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->Name == "object5_type2_mode2"); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0]->PreDeleteObjectCount == 0); + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 0); + TEST_ASSERT(CType3::Type3Objects.size() == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 0); + TEST_ASSERT(CType4::Type4Objects.size() == 0); + } + + // step 2 + void changedContent() + { + installStepFiles("step_2"); + + // Cleanup search path + CPath::clearMap(); + + // Add the primitive cfg in the search path + CPath::addSearchFile("../tmp/primitives.cfg"); + + // And load the primitives + CPrimitiveObjectManager::getInstance()->updatePrimitives(); + + // Do various checks on objects & counters + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 3); + TEST_ASSERT(CType1::Type1Objects.size() == 3); + + TEST_ASSERT(CType1::Type1Objects[0]->PreUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[0]->UpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[0]->PostUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[0]->PreDeleteCount== 1); + TEST_ASSERT(CType1::Type1Objects[0]->Name == "object1_type1"); + TEST_ASSERT(CType1::Type1Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[0]->PreDeleteObjectCount == 2); + + TEST_ASSERT(CType1::Type1Objects[1]->PreUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[1]->UpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[1]->PostUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteCount== 1); + TEST_ASSERT(CType1::Type1Objects[1]->Name == "object2_type1"); + TEST_ASSERT(CType1::Type1Objects[1]->Value == "changed_value_1"); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteObjectCount == 2); + + TEST_ASSERT(CType1::Type1Objects[2]->PreUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[2]->UpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[2]->PostUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteCount== 1); + TEST_ASSERT(CType1::Type1Objects[2]->Name == "object3_type1"); + TEST_ASSERT(CType1::Type1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteObjectCount == 2); + + counter = NL_GET_INSTANCE_COUNTER(CType2Mode1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 2); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->getAlias() == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreUpdateCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->UpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PostUpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Name == "object7_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteObjectCount == 0); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->getAlias() == 6); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PreUpdateCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->UpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PostUpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->Name == "object6_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PreDeleteObjectCount == 0); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 1); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 0); + TEST_ASSERT(CType3::Type3Objects.size() == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 0); + TEST_ASSERT(CType4::Type4Objects.size() == 0); + } + + // step 3 + void addedPrimitive() + { + installStepFiles("step_3"); + + // Cleanup search path + CPath::clearMap(); + + // Add the primitive cfg in the search path + CPath::addSearchFile("../tmp/primitives.cfg"); + + // And load the primitives + CPrimitiveObjectManager::getInstance()->updatePrimitives(); + + // Do various checks on objects & counters + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 4); + TEST_ASSERT(CType1::Type1Objects.size() == 4); + + TEST_ASSERT(CType1::Type1Objects[0]->PreUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[0]->UpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[0]->PostUpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[0]->PreDeleteCount== 1); + TEST_ASSERT(CType1::Type1Objects[0]->Name == "object1_type1"); + TEST_ASSERT(CType1::Type1Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[0]->PreDeleteObjectCount == 2); + + TEST_ASSERT(CType1::Type1Objects[1]->PreUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[1]->UpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[1]->PostUpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteCount== 1); + TEST_ASSERT(CType1::Type1Objects[1]->Name == "object2_type1"); + TEST_ASSERT(CType1::Type1Objects[1]->Value == "changed_value_1"); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteObjectCount == 2); + + TEST_ASSERT(CType1::Type1Objects[2]->PreUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[2]->UpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[2]->PostUpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteCount== 1); + TEST_ASSERT(CType1::Type1Objects[2]->Name == "object3_type1"); + TEST_ASSERT(CType1::Type1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteObjectCount == 2); + + TEST_ASSERT(CType1::Type1Objects[3]->PreUpdateCount == 0); + TEST_ASSERT(CType1::Type1Objects[3]->UpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[3]->PostUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[3]->PreDeleteCount== 0); + TEST_ASSERT(CType1::Type1Objects[3]->Name == "object8_type1"); + TEST_ASSERT(CType1::Type1Objects[3]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[3]->PreDeleteObjectCount == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType2Mode1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 4); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->getAlias() == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreUpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->UpdateCount == 2); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PostUpdateCount == 2); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Name == "object7_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteObjectCount == 0); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->getAlias() == 6); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PreUpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->UpdateCount == 2); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PostUpdateCount == 2); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->Name == "object6_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2]->PreDeleteObjectCount == 0); + + TAIAlias alias = CType2Mode1::Type2Mode1Objects[3]->getAlias(); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->getAlias() == CPrimitiveLoader::getInstance()->getLigoConfig().buildAlias(1, 2)); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->PreUpdateCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->UpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->PostUpdateCount == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->Name == "object9_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3]->PreDeleteObjectCount == 0); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 1); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 2); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0] == NULL); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->getAlias() == CPrimitiveLoader::getInstance()->getLigoConfig().buildAlias(1, 3)); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->PreUpdateCount == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->UpdateCount == 1); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->PostUpdateCount == 1); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->PreDeleteCount == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->Name == "object10_type2_mode2"); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1]->PreDeleteObjectCount == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 0); + TEST_ASSERT(CType3::Type3Objects.size() == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 0); + TEST_ASSERT(CType4::Type4Objects.size() == 0); + } + + // step 4 + void removedContent() + { + installStepFiles("step_4"); + + // Cleanup search path + CPath::clearMap(); + + // Add the primitive cfg in the search path + CPath::addSearchFile("../tmp/primitives.cfg"); + + // And load the primitives + CPrimitiveObjectManager::getInstance()->updatePrimitives(); + + // Do various checks on objects & counters + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 3); + TEST_ASSERT(CType1::Type1Objects.size() == 4); + + TEST_ASSERT(CType1::Type1Objects[0] == NULL); + + TEST_ASSERT(CType1::Type1Objects[1]->PreUpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[1]->UpdateCount == 4); + TEST_ASSERT(CType1::Type1Objects[1]->PostUpdateCount == 4); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteCount == 3); + TEST_ASSERT(CType1::Type1Objects[1]->Name == "object2_type1"); + TEST_ASSERT(CType1::Type1Objects[1]->Value == "changed_value_1"); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteObjectCount == 6); + + TEST_ASSERT(CType1::Type1Objects[2]->PreUpdateCount == 3); + TEST_ASSERT(CType1::Type1Objects[2]->UpdateCount == 4); + TEST_ASSERT(CType1::Type1Objects[2]->PostUpdateCount == 4); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteCount== 3); + TEST_ASSERT(CType1::Type1Objects[2]->Name == "object3_type1"); + TEST_ASSERT(CType1::Type1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteObjectCount == 6); + + TEST_ASSERT(CType1::Type1Objects[3]->PreUpdateCount == 1); + TEST_ASSERT(CType1::Type1Objects[3]->UpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[3]->PostUpdateCount == 2); + TEST_ASSERT(CType1::Type1Objects[3]->PreDeleteCount == 2); + TEST_ASSERT(CType1::Type1Objects[3]->Name == "object8_type1"); + TEST_ASSERT(CType1::Type1Objects[3]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[3]->PreDeleteObjectCount == 4); + + counter = NL_GET_INSTANCE_COUNTER(CType2Mode1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 4); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->getAlias() == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreUpdateCount == 2); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->UpdateCount == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PostUpdateCount == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteCount == 2); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Name == "object7_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteObjectCount == 4); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3] == NULL); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 2); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0] == NULL); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 0); + TEST_ASSERT(CType3::Type3Objects.size() == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 0); + TEST_ASSERT(CType4::Type4Objects.size() == 0); + } + + // step 5 + void removedPrimitive() + { + installStepFiles("step_5"); + + // Cleanup search path + CPath::clearMap(); + + // Add the primitive cfg in the search path + CPath::addSearchFile("../tmp/primitives.cfg"); + + // And load the primitives + CPrimitiveObjectManager::getInstance()->updatePrimitives(); + + // Do various checks on objects & counters + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 2); + TEST_ASSERT(CType1::Type1Objects.size() == 4); + + TEST_ASSERT(CType1::Type1Objects[0] == NULL); + + TEST_ASSERT(CType1::Type1Objects[1]->PreUpdateCount == 4); + TEST_ASSERT(CType1::Type1Objects[1]->UpdateCount == 5); + TEST_ASSERT(CType1::Type1Objects[1]->PostUpdateCount == 5); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteCount == 4); + TEST_ASSERT(CType1::Type1Objects[1]->Name == "object2_type1"); + TEST_ASSERT(CType1::Type1Objects[1]->Value == "changed_value_1"); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteObjectCount == 7); + + TEST_ASSERT(CType1::Type1Objects[2]->PreUpdateCount == 4); + TEST_ASSERT(CType1::Type1Objects[2]->UpdateCount == 5); + TEST_ASSERT(CType1::Type1Objects[2]->PostUpdateCount == 5); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteCount== 4); + TEST_ASSERT(CType1::Type1Objects[2]->Name == "object3_type1"); + TEST_ASSERT(CType1::Type1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteObjectCount == 7); + + TEST_ASSERT(CType1::Type1Objects[3] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType2Mode1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 4); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->getAlias() == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreUpdateCount == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->UpdateCount == 4); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PostUpdateCount == 4); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteCount == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Name == "object7_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteObjectCount == 5); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3] == NULL); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 2); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0] == NULL); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 0); + TEST_ASSERT(CType3::Type3Objects.size() == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 0); + TEST_ASSERT(CType4::Type4Objects.size() == 0); + } + + // step 6 + void mutiObject() + { + installStepFiles("step_6"); + + // Cleanup search path + CPath::clearMap(); + + // Add the primitive cfg in the search path + CPath::addSearchFile("../tmp/primitives.cfg"); + + // And load the primitives + CPrimitiveObjectManager::getInstance()->updatePrimitives(); + + // Do various checks on objects & counters + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 2); + TEST_ASSERT(CType1::Type1Objects.size() == 4); + + TEST_ASSERT(CType1::Type1Objects[0] == NULL); + + TEST_ASSERT(CType1::Type1Objects[1]->PreUpdateCount == 5); + TEST_ASSERT(CType1::Type1Objects[1]->UpdateCount == 6); + TEST_ASSERT(CType1::Type1Objects[1]->PostUpdateCount == 6); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteCount == 4); + TEST_ASSERT(CType1::Type1Objects[1]->Name == "object2_type1"); + TEST_ASSERT(CType1::Type1Objects[1]->Value == "changed_value_1"); + TEST_ASSERT(CType1::Type1Objects[1]->PreDeleteObjectCount == 7); + + TEST_ASSERT(CType1::Type1Objects[2]->PreUpdateCount == 5); + TEST_ASSERT(CType1::Type1Objects[2]->UpdateCount == 6); + TEST_ASSERT(CType1::Type1Objects[2]->PostUpdateCount == 6); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteCount== 4); + TEST_ASSERT(CType1::Type1Objects[2]->Name == "object3_type1"); + TEST_ASSERT(CType1::Type1Objects[2]->Value == "initial_value"); + TEST_ASSERT(CType1::Type1Objects[2]->PreDeleteObjectCount == 7); + + TEST_ASSERT(CType1::Type1Objects[3] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType2Mode1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 1); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 4); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->getAlias() == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreUpdateCount == 4); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->UpdateCount == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PostUpdateCount == 5); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteCount == 3); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Name == "object7_type2_mode1"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->Value == "initial_value"); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1]->PreDeleteObjectCount == 5); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3] == NULL); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 2); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0] == NULL); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 1); + TEST_ASSERT(CType3::Type3Objects.size() == 1); + + TEST_ASSERT(CType3::Type3Objects[0]->getAlias() == 6); + TEST_ASSERT(CType3::Type3Objects[0]->PreUpdateCount == 0); + TEST_ASSERT(CType3::Type3Objects[0]->UpdateCount == 1); + TEST_ASSERT(CType3::Type3Objects[0]->PostUpdateCount == 1); + TEST_ASSERT(CType3::Type3Objects[0]->PreDeleteCount == 0); + TEST_ASSERT(CType3::Type3Objects[0]->Name == "object8_poly_type"); + TEST_ASSERT(CType3::Type3Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType3::Type3Objects[0]->PreDeleteObjectCount == 0); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 1); + TEST_ASSERT(CType4::Type4Objects.size() == 1); + + TEST_ASSERT(CType4::Type4Objects[0]->getAlias() == 6); + TEST_ASSERT(CType4::Type4Objects[0]->PreUpdateCount == 0); + TEST_ASSERT(CType4::Type4Objects[0]->UpdateCount == 1); + TEST_ASSERT(CType4::Type4Objects[0]->PostUpdateCount == 1); + TEST_ASSERT(CType4::Type4Objects[0]->PreDeleteCount == 0); + TEST_ASSERT(CType4::Type4Objects[0]->Name == "object8_poly_type"); + TEST_ASSERT(CType4::Type4Objects[0]->Value == "initial_value"); + TEST_ASSERT(CType4::Type4Objects[0]->PreDeleteObjectCount == 0); + + } + + // step 7 + void fullCleanup() + { + installStepFiles("step_7"); + + // Cleanup search path + CPath::clearMap(); + + // Add the primitive cfg in the search path + CPath::addSearchFile("../tmp/primitives.cfg"); + + // And load the primitives + CPrimitiveObjectManager::getInstance()->updatePrimitives(); + + // Do various checks on objects & counters + + uint32 counter = NL_GET_INSTANCE_COUNTER(CType1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType1) == 0); + TEST_ASSERT(CType1::Type1Objects.size() == 4); + + TEST_ASSERT(CType1::Type1Objects[0] == NULL); + + TEST_ASSERT(CType1::Type1Objects[1] == NULL); + + TEST_ASSERT(CType1::Type1Objects[2] == NULL); + + TEST_ASSERT(CType1::Type1Objects[3] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType2Mode1); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode1) == 0); + TEST_ASSERT(CType2Mode1::Type2Mode1Objects.size() == 4); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[0] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[1] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[2] == NULL); + + TEST_ASSERT(CType2Mode1::Type2Mode1Objects[3] == NULL); + + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType2Mode2) == 0); + TEST_ASSERT(CType2Mode2::Type2Mode2Objects.size() == 2); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[0] == NULL); + + TEST_ASSERT(CType2Mode2::Type2Mode2Objects[1] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType3); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType3) == 0); + TEST_ASSERT(CType3::Type3Objects.size() == 1); + + TEST_ASSERT(CType3::Type3Objects[0] == NULL); + + counter = NL_GET_INSTANCE_COUNTER(CType4); + TEST_ASSERT(NL_GET_INSTANCE_COUNTER(CType4) == 0); + TEST_ASSERT(CType4::Type4Objects.size() == 1); + + TEST_ASSERT(CType4::Type4Objects[0] == NULL); + + } +}; + + +Test::Suite *createPrimitiveObjectTS(const std::string &workingPath) +{ + return static_cast(new CPrimitiveObjectTS(workingPath)); +} + diff --git a/code/ryzom/tools/server/test_modules/game_share_test/test_module_interface.cpp b/code/ryzom/tools/server/test_modules/game_share_test/test_module_interface.cpp new file mode 100644 index 000000000..194964015 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/game_share_test/test_module_interface.cpp @@ -0,0 +1,246 @@ + + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/dynloadlib.h" +#include "nel/misc/path.h" + +#include "nel/net/unified_network.h" +#include "nel/net/module.h" +#include "nel/net/module_manager.h" +#include "nel/net/module_builder_parts.h" + + +#include "src/cpptest.h" + +#include "test_module_itf.h" + + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace TST_MOD_ITF; + +//class A +//{ +//public: +// void getParentFromA() +// { +// getParent("A"); +// } +// virtual void getParent(const char*) =0; +//}; +// +//class B +//{ +//public: +// void getParentFromB() +// { +// getParent("B"); +// } +// virtual void getParent(const char*) =0; +//}; +// +// +//class C +//: public A, B +//{ +//public: +// +// C() +// { +// getParentFromA(); +// getParentFromB(); +// } +// +// virtual void getParent(const char*childName) +// { +// printf("Child %s called getParent", childName); +// } +//}; +// +//C c; +// +//class D +//{ +// virtual void getParent(const char*childName) +// { +// printf("Child %s called getParent", childName); +// } +//}; + +class CModuleServant + : public CEmptyModuleServiceBehav > >, + public CTestModuleInterfaceSkel +{ + bool _ImmediateDispatching; + +public: + + CModuleServant() + { + CTestModuleInterfaceSkel::init(this); + _ImmediateDispatching = false; + } + + bool isImmediateDispatchingSupported() const + { + return _ImmediateDispatching; + } + +// void onProcessModuleMessage(IModuleProxy *sender, const CMessage &message) +// { +// if (CTestModuleInterfaceSkel::onDispatchMessage(sender, message)) +// return; +// +// nlassert(false); +// } + + void noParam(NLNET::IModuleProxy *sender) + { + } + + uint32 twoWayInvoke(NLNET::IModuleProxy *sender, uint32 value1, uint32 value2) + { + return value1+value2; + } + + void setImmediateDispatching(bool value) + { + _ImmediateDispatching = value; + } + +}; + +NLNET_REGISTER_MODULE_FACTORY(CModuleServant, "ModuleServant"); + + +class CModuleClient + : public CEmptyModuleServiceBehav > > +{ +public: + TModuleProxyPtr Servant; + bool TaskRunning; + + uint32 Result; + + void startTask() + { + TaskRunning = true; + NLNET_START_MODULE_TASK(CModuleClient, taskFunc); + } + + void onModuleUp(IModuleProxy *proxy) + { + if (proxy->getModuleClassName() == "ModuleServant") + { + Servant = proxy; + } + } + + void onModuleDown(IModuleProxy *proxy) + { + if (proxy == Servant) + Servant = NULL; + } + + void taskFunc() + { + while (Servant == NULL) + { + if (getActiveModuleTask()->isTerminationRequested()) + return; + + getActiveModuleTask()->yield(); + } + CTestModuleInterfaceProxy tmi(Servant); + + Result = tmi.twoWayInvoke(this, 32, 4); + TaskRunning = false; + } + + void callImmediat() + { + nlassert(Servant != NULL); + CTestModuleInterfaceProxy tmi(Servant); + Result = tmi.twoWayInvoke(this, 32, 4); + } + +}; + + +NLNET_REGISTER_MODULE_FACTORY(CModuleClient, "ModuleClient"); + + +class CModuleInterfaceTS: public Test::Suite +{ + +public: + CModuleInterfaceTS() + { + TEST_ADD(CModuleInterfaceTS::testTwoWay); + + } + + void testTwoWay() + { + // create two modules and test the two way invocation protocol + + IModuleManager::getInstance(); + CCommandRegistry &cr = CCommandRegistry::getInstance(); + + cr.execute("moduleManager.createModule StandardGateway gw", InfoLog()); + cr.execute("moduleManager.createModule ModuleServant srv", InfoLog()); + cr.execute("moduleManager.createModule ModuleClient clt", InfoLog()); + + // plug the modules + cr.execute("srv.plug gw", InfoLog()); + cr.execute("clt.plug gw", InfoLog()); + + // retreive the client module + IModule *mod = IModuleManager::getInstance().getLocalModule("clt"); + TEST_ASSERT(mod != NULL); + CModuleClient *client = dynamic_cast(mod); + TEST_ASSERT(client != NULL); + CModuleServant *servant = dynamic_cast(IModuleManager::getInstance().getLocalModule("srv")); + TEST_ASSERT(servant != NULL); + + client->startTask(); + + // update the modules + for (uint i=0; i<10; ++i) + { + IModuleManager::getInstance().updateModules(); + nlSleep(10); + } + + // check that the client have received the response + TEST_ASSERT(client->TaskRunning == false); + // check that the result is ok + TEST_ASSERT(client->Result == 36); + + + // Retry with immediate dispatching and direct call thank to the interface gernerator + client->Result = 0; + servant->setImmediateDispatching(true); + + client->callImmediat(); + // check that the result is ok + TEST_ASSERT(client->Result == 36); + + // cleanup + // detroy the modules + cr.execute("moduleManager.deleteModule gw", InfoLog()); + cr.execute("moduleManager.deleteModule srv", InfoLog()); + cr.execute("moduleManager.deleteModule clt", InfoLog()); + } + +}; + +Test::Suite *createModuleInterfaceTS() +{ + return static_cast(new CModuleInterfaceTS()); +} + + + diff --git a/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.cpp b/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.cpp new file mode 100644 index 000000000..041bc4795 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.cpp @@ -0,0 +1,145 @@ + +///////////////////////////////////////////////////////////////// +// WARNING : this is a generated file, don't change it ! +///////////////////////////////////////////////////////////////// + +#include "test_module_itf.h" + +namespace TST_MOD_ITF +{ + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + + + const CTestModuleInterfaceSkel::TMessageHandlerMap &CTestModuleInterfaceSkel::getMessageHandlers() const + { + static TMessageHandlerMap handlers; + static bool init = false; + + if (!init) + { + std::pair < TMessageHandlerMap::iterator, bool > res; + + res = handlers.insert(std::make_pair(std::string("TMI_NP"), &CTestModuleInterfaceSkel::noParam_skel)); + // if this assert, you have a doubly message name in your interface definition ! + nlassert(res.second); + + res = handlers.insert(std::make_pair(std::string("TMI_TWI"), &CTestModuleInterfaceSkel::twoWayInvoke_skel)); + // if this assert, you have a doubly message name in your interface definition ! + nlassert(res.second); + + init = true; + } + + return handlers; + } + bool CTestModuleInterfaceSkel::fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message) + { + const TMessageHandlerMap &mh = getMessageHandlers(); + + TMessageHandlerMap::const_iterator it(mh.find(message.getName())); + + if (it == mh.end()) + { + return false; + } + + TMessageHandler cmd = it->second; + (this->*cmd)(sender, message); + + return true; + } + + + void CTestModuleInterfaceSkel::noParam_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message) + { + H_AUTO(CTestModuleInterfaceSkel_noParam_TMI_NP); + noParam(sender); + } + + void CTestModuleInterfaceSkel::twoWayInvoke_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message) + { + H_AUTO(CTestModuleInterfaceSkel_twoWayInvoke_TMI_TWI); + uint32 value1; + nlRead(__message, serial, value1); + uint32 value2; + nlRead(__message, serial, value2); + uint32 __ret = twoWayInvoke(sender, value1, value2); + // encode the return message + NLNET::CMessage __retMsg; + __retMsg.setType("R_TMI_TWI", NLNET::CMessage::Response); + nlWrite(__retMsg, serial, __ret); + + // and send back the response + sender->sendModuleMessage(static_cast(_Interceptor.getRegistrar()), __retMsg); + + } + void CTestModuleInterfaceProxy::noParam(NLNET::IModule *sender) + { + if (_LocalModuleSkel && _LocalModule->isImmediateDispatchingSupported()) + { + // immediate local synchronous dispatching + _LocalModuleSkel->noParam(_ModuleProxy->getModuleGateway()->getPluggedModuleProxy(sender)); + } + else + { + // send the message for remote dispatching and execution or local queing + NLNET::CMessage __message; + + buildMessageFor_noParam(__message); + + _ModuleProxy->sendModuleMessage(sender, __message); + } + } + uint32 CTestModuleInterfaceProxy::twoWayInvoke(NLNET::IModule *sender, uint32 value1, uint32 value2) + { + if (_LocalModuleSkel && _LocalModule->isImmediateDispatchingSupported()) + { + // immediate local synchronous dispatching + return _LocalModuleSkel->twoWayInvoke(_ModuleProxy->getModuleGateway()->getPluggedModuleProxy(sender), value1, value2); + } + else + { + // send the message for remote dispatching and execution + + NLNET::CMessage __message; + + buildMessageFor_twoWayInvoke(__message, value1, value2); + + NLNET::CMessage __retMsg; + sender->invokeModuleOperation(_ModuleProxy, __message, __retMsg); + + // check the return message type + if (__retMsg.getName() != "R_TMI_TWI") + throw NLNET::IModule::EInvokeBadReturn(); + + uint32 __ret; + nlRead(__retMsg, serial, __ret); + + return __ret; + } + } + + // Message serializer. Return the message received in reference for easier integration + const NLNET::CMessage &CTestModuleInterfaceProxy::buildMessageFor_noParam(NLNET::CMessage &__message) + { + __message.setType("TMI_NP"); + + + return __message; + } + + // Message serializer. Return the message received in reference for easier integration + const NLNET::CMessage &CTestModuleInterfaceProxy::buildMessageFor_twoWayInvoke(NLNET::CMessage &__message, uint32 value1, uint32 value2) + { + __message.setType("TMI_TWI", NLNET::CMessage::Request); + nlWrite(__message, serial, value1); + nlWrite(__message, serial, value2); + + + return __message; + } + +} diff --git a/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.h b/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.h new file mode 100644 index 000000000..b44a447c0 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.h @@ -0,0 +1,143 @@ + +///////////////////////////////////////////////////////////////// +// WARNING : this is a generated file, don't change it ! +///////////////////////////////////////////////////////////////// + +#ifndef TEST_MODULE_INTERFACE +#define TEST_MODULE_INTERFACE +#include "nel/misc/hierarchical_timer.h" +#include "nel/misc/string_conversion.h" +#include "nel/net/message.h" +#include "nel/net/module.h" +#include "nel/net/module_builder_parts.h" +#include "nel/net/module_message.h" +#include "nel/net/module_gateway.h" + +namespace TST_MOD_ITF +{ + + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + class CTestModuleInterfaceSkel + { + public: + /// the interceptor type + typedef NLNET::CInterceptorForwarder < CTestModuleInterfaceSkel> TInterceptor; + protected: + CTestModuleInterfaceSkel() + { + // do early run time check for message table + getMessageHandlers(); + } + virtual ~CTestModuleInterfaceSkel() + { + } + + void init(NLNET::IModule *module) + { + _Interceptor.init(this, module); + } + + public: + + + // unused interceptors + std::string fwdBuildModuleManifest() const { return std::string(); } + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + + // process module message interceptor + bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); + private: + + typedef void (CTestModuleInterfaceSkel::*TMessageHandler)(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); + typedef std::map TMessageHandlerMap; + + const TMessageHandlerMap &getMessageHandlers() const; + + + void noParam_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message); + + void twoWayInvoke_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message); + + // declare one interceptor member of the skeleton + TInterceptor _Interceptor; + + // declare the interceptor forwarder as friend of this class + friend class NLNET::CInterceptorForwarder < CTestModuleInterfaceSkel>; + public: + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + + virtual void noParam(NLNET::IModuleProxy *sender) =0; + virtual uint32 twoWayInvoke(NLNET::IModuleProxy *sender, uint32 value1, uint32 value2) =0; + + + }; + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + class CTestModuleInterfaceProxy + { + /// Smart pointer on the module proxy + NLNET::TModuleProxyPtr _ModuleProxy; + + // Pointer on the local module that implement the interface (if the proxy is for a local module) + NLNET::TModulePtr _LocalModule; + // Direct pointer on the server implementation interface for collocated module + CTestModuleInterfaceSkel *_LocalModuleSkel; + + + public: + CTestModuleInterfaceProxy(NLNET::IModuleProxy *proxy) + { + + _ModuleProxy = proxy; + + // initialize collocated servant interface + if (proxy->getModuleDistance() == 0) + { + _LocalModule = proxy->getLocalModule(); + nlassert(_LocalModule != NULL); + CTestModuleInterfaceSkel::TInterceptor *interceptor = NULL; + interceptor = static_cast < NLNET::CModuleBase* >(_LocalModule.getPtr())->getInterceptor(interceptor); + nlassert(interceptor != NULL); + + _LocalModuleSkel = interceptor->getParent(); + nlassert(_LocalModuleSkel != NULL); + } + else + _LocalModuleSkel = 0; + + } + virtual ~CTestModuleInterfaceProxy() + { + } + + NLNET::IModuleProxy *getModuleProxy() + { + return _ModuleProxy; + } + + void noParam(NLNET::IModule *sender); + uint32 twoWayInvoke(NLNET::IModule *sender, uint32 value1, uint32 value2); + + // Message serializer. Return the message received in reference for easier integration + static const NLNET::CMessage &buildMessageFor_noParam(NLNET::CMessage &__message); + + // Message serializer. Return the message received in reference for easier integration + static const NLNET::CMessage &buildMessageFor_twoWayInvoke(NLNET::CMessage &__message, uint32 value1, uint32 value2); + + + + + }; + +} + +#endif diff --git a/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.xml b/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.xml new file mode 100644 index 000000000..4f105ff2f --- /dev/null +++ b/code/ryzom/tools/server/test_modules/game_share_test/test_module_itf.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/test_modules/session_browser_test/session_browser_test.cpp b/code/ryzom/tools/server/test_modules/session_browser_test/session_browser_test.cpp new file mode 100644 index 000000000..0fec5f434 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/session_browser_test/session_browser_test.cpp @@ -0,0 +1,388 @@ + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/dynloadlib.h" +#include "nel/misc/path.h" +#include "nel/net/service.h" +#include "nel/net/module_manager.h" + +#include "src/cpptest.h" + +#include "game_share/mysql_wrapper.h" + + +#include "client/session_browser.h" + + +#include +#include + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace RSMGR; + + +extern void session_browser_force_link(); + +void foo() +{ + session_browser_force_link(); +} + + +const nbUserField = 4; +const char *userData[][nbUserField] = +{ + { "10000", "test_user1", "DF01A8C0|0674E006|00002710", "cs_offline"}, + { "10001", "test_user2", "DF01A8C0|0674E006|00002711", "cs_online"}, + { "268435455", "bad_user", "DF01A8C0|0674E006|FFFFFFFF", "cs_online"}, +}; + + +class CSessionBrowserTS + : public Test::Suite, + public CSessionBrowser +{ + string _WorkingPath; +// string _BaseDir; +// string _CurrentPath; +// string _CurrentPathToRestore; + + bool _ConnFailed; + bool _DisconnectionReceived; + bool _SessionReceived; + std::vector < TSessionDesc > _Sessions; + + MSW::CConnection _RingDb; + + IService _Service; + + +public: + + CSessionBrowserTS(const std::string &workingPath) + { + _WorkingPath = workingPath; + + NLMISC::createDebug(); + + + // add a variable + CConfigFile::CVar mainlandNames; + mainlandNames.Type = CConfigFile::CVar::T_STRING; + mainlandNames.StrValues.resize(9); + mainlandNames.setAsString("101", 0); + mainlandNames.setAsString("Aniro", 1); + mainlandNames.setAsString("ani", 2); + mainlandNames.setAsString("102", 3); + mainlandNames.setAsString("Leanon", 4); + mainlandNames.setAsString("lea", 5); + mainlandNames.setAsString("103", 6); + mainlandNames.setAsString("Arispotle", 7); + mainlandNames.setAsString("ari", 8); + + IService::getInstance()->ConfigFile.insertVar("HomeMainlandNames", mainlandNames); + + // check database population + nlverify(_RingDb.connect("borisb2", "root", "", "ring")); + + + CCommandRegistry &cr = CCommandRegistry::getInstance(); + cr.execute("moduleManager.createModule StandardGateway gw", InfoLog()); + cr.execute("moduleManager.createModule SessionBrowserServerMod sbs suAddr=localhost:49999 listenPort=1234 ring_db(host=borisb2 user=ring password= base=ring)", InfoLog()); + cr.execute("suc.plug gw", InfoLog()); + + + // fill the database with some users + + // cleanup the previously created users + CSString query; + query << "DELETE FROM ring_users WHERE user_id >= 10000"; + _RingDb.query(query); + + for (uint i=0; i of the + // Front end that waits for the player to come in and the. + // participation mode for the character (editor, animator or player). + // If ok, the web must return a page with a lua script. + // that trigger the action handler 'on_connect_to_shard' : + // runAH(nul, "on_connect_to_shard", "cookie=cookieValue|fsAddr=shardAddr|mode=participantStatus"); + // result : 0 : ok the client can join the session + // 1 : char not found + // 2 : session not found + // 3 : no session participant for this character (not used for a mainland shard) + // 4 : can't find session server (not used for a mainland shard) + // 5 : shard hosting session is not reachable + // 6 : nel user info not found + // 7 : ring user not found + // 8 : welcome service rejected connection request + // 9 : session service shutdown (not used for a mainland shard) + // 10 : no mainland shard found (joinMainland only) + // 11 : internal error + // 12 : failed to request for access permission + // 13 : can't find access permission for user and domain + // 14 : Welcome service is closed for you + virtual void on_joinSessionResult(NLNET::TSockId from, uint32 userId, uint32 result, const std::string &shardAddr, const std::string &participantStatus) + { + nlstop; + } + + // Return the list of online shards on which the user is allowed to connect, + // and their current dynamic attributes. Other attributes (e.g. names) + // can be queried from the database. Offline shards are the ones in the database + // of the same domain but not listed in the result. + // Then the client will have to call joinShard to connect on an online shard. + virtual void on_getShardsResult(NLNET::TSockId from, uint32 userId, const std::string &result) + { + nlstop; + } + + + /////////////////////////////////////////////////////////////////////// + // + /////////////////////////////////////////////////////////////////////// + /// Disconnection callback : the connection to the server is lost + virtual void on_CSessionBrowserServerWebClient_Disconnection(NLNET::TSockId from) + { + nldebug("Lost connection with server"); + + _DisconnectionReceived = true; + } + + // Return the list of available session + virtual void on_sessionList(NLNET::TSockId from, uint32 charId, const std::vector < TSessionDesc > &sessions) + { + _SessionReceived = true; + _Sessions = sessions; + } + + /////////////////////////////////////////////////////////////////////// + // + /////////////////////////////////////////////////////////////////////// + virtual void on_connectionFailed() + { + _ConnFailed = true; + } + +// // The connection has been closed. +// virtual void on_connectionClosed() +// { +// nlstop; +// } + +}; + +NLMISC::CApplicationContext *Context; + +auto_ptr intRegisterTestSuite(const std::string &workingPath) +{ + + Context = new CApplicationContext(); + // init a new nel instance + INelContext::getInstance(); + // init the module manager + IModuleManager::getInstance(); + return static_cast(new CSessionBrowserTS(workingPath)); +} + +NL_LIB_EXPORT_SYMBOL(registerTestSuite, void, intRegisterTestSuite); + diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/character_sync_test.cpp b/code/ryzom/tools/server/test_modules/shard_unifier_test/character_sync_test.cpp new file mode 100644 index 000000000..e1740bd6f --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/character_sync_test.cpp @@ -0,0 +1,336 @@ +/** Test file for the ring sesison manager module */ + +#include "nel/misc/types_nl.h" +#include "nel/misc/command.h" + +#include "nel/net/module.h" +#include "nel/net/module_builder_parts.h" +#include "nel/net/module_manager.h" +#include "nel/net/unified_network.h" +#include "nel/net/service.h" + +#include "src/cpptest.h" + +#include "game_share/mysql_wrapper.h" +#include "entities_game_service/player_manager/player_manager_interface.h" +#include "entities_game_service/player_manager/character_interface.h" +#include "entities_game_service/modules/shard_unifier_client.h" +#include "entities_game_service/modules/char_name_mapper_client.h" +#include "shard_unifier_service/database_mapping.h" + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace RSMGR; + +// some globals for the test +static TSessionId sessionId(0); + +uint32 userId1 = 1; +static uint32 charId = (userId1*16)+0; + +uint32 userId2 = 2; +static uint32 invitedCharId = (userId2*16)+0; + +class CPlayer; + +void sendCharactersSummary( CPlayer *player, bool AllAutorized) +{ +} + +/** Interface to the char name mapper client singleton */ +class CCharNameMapperClient : public ICharNameMapperClient +{ +public: + + void mapCharacterName(const NLMISC::CEntityId &charEid, const ucstring &charName) + { + + } +}; + +CCharNameMapperClient charNameMapper; + + +class CCharacter; + +class CPHCharacter : public ICharacter +{ + virtual const NLMISC::CEntityId& getCharId() const + { + static NLMISC::CEntityId eid; + return eid; + } + + virtual void setName(const ucstring &name) + { + + } + + virtual bool getEnterFlag() const + { + return true; + } + + virtual uint32 getLastDisconnectionDate() + { + return 0; + } +}; + +ICharacter *ICharacter::getInterface(::CCharacter *character, bool onlyOnline) +{ + return NULL; +} + +ICharacter *ICharacter::getInterface(uint32 charId, bool onlyOnline) +{ + return NULL; +} + +void cbCreateChar_part2(uint32 userId, const CCreateCharMsg &createCharMsg, bool ok) +{ +} + +void sendIfNameIsValide( uint32 userId, bool nameValide ) +{ +} + +class CPlayerManagerPH : public IPlayerManager +{ + TMapPlayers _Players; + + virtual const TMapPlayers& getPlayers() + { + return _Players; + } + + /** Get the active character for the given player id */ + virtual ::CCharacter * getActiveChar( uint32 userId ) + { + return NULL; + } + + /** Get the specified character of a player */ + virtual ::CCharacter * getChar( uint32 userId, uint32 index ) + { + return NULL; + } + + /** A character has been renamed by name unifier */ + virtual void characterRenamed(uint32 charId, const std::string &newName) + { + + } + + virtual void sendImpulseToClient(const NLMISC::CEntityId & id, const std::string & msgName ) + { + + } + + virtual void addAllCharForStringIdRequest() + { + } + + virtual void addEntityForStringIdRequest(const NLMISC::CEntityId &eid) + { + } + + virtual void checkContactLists() + { + } + + virtual void playerEntityRemoved(const NLMISC::CEntityId &eid) + { + } + + + +}; + +CPlayerManagerPH playerManager; + +IPlayerManager *IPlayerManager::_Instance = NULL; + +class CTestService : public NLNET::IService +{ + +}; + +class CCharacterSyncTS: public Test::Suite +{ + MSW::CConnection _Conn; + + string OldPath; + +public: + CCharacterSyncTS(const std::string &workingPath) + { + OldPath = CPath::getCurrentPath(); + + CPath::setCurrentPath(workingPath.c_str()); + + // force instanciation of the module manager + IModuleManager::getInstance(); + // create the session manager module + CCommandRegistry &cr = CCommandRegistry::getInstance(); + + string DBHost = "borisb2"; + + // create a pseudo service + CTestService service; + service.setArgs("-Zu"); + service.main("TS", "test_service", 0, ".", ".", ""); + service.anticipateShardId(100); + + cr.execute("addNegativeFilterInfo EIT", InfoLog()); + + cr.execute("moduleManager.createModule StandardGateway gw", InfoLog()); + cr.execute("moduleManager.createModule ShardUnifierClient suc", InfoLog()); + cr.execute("suc.plug gw", InfoLog()); + cr.execute("moduleManager.createModule CharacterSynchronisation cs ring_db(host="+DBHost+" user=root password= base=ring) nel_db(host="+DBHost+" user=root password= base=nel)", InfoLog()); + cr.execute("cs.plug gw", InfoLog()); + + // check module creation + nlassert(IModuleManager::getInstance().getLocalModule("suc") != NULL); + nlassert(IModuleManager::getInstance().getLocalModule("cs") != NULL); + nlassert(IModuleManager::getInstance().getLocalModule("gw") != NULL); + + // check database population + nlverify(_Conn.connect(DBHost, "root", "", "ring")); + + // check the first user id + CRingUserPtr ru = CRingUser::load(_Conn, userId1, __FILE__, __LINE__); + if (ru == NULL) + { + // create a new record + ru = CRingUser::createTransient(__FILE__, __LINE__); + + ru->setUserName("toto"); +// ru->setCurrentSession(0); + + nlverify(ru->create(_Conn)); + + userId1 = ru->getObjectId(); + } + + charId = (userId1 * 16)+0; + + // check the character + CCharacterPtr character = RSMGR::CCharacter::load(_Conn, charId, __FILE__, __LINE__); + if (character == NULL) + { + // create a character + character = RSMGR::CCharacter::createTransient(__FILE__, __LINE__); + + character->setObjectId(charId); + character->setCharName("toto_char"); + character->setUserId(userId1); + character->setGuildId(0); + character->setBestCombatLevel(100); + + nlverify(character->create(_Conn)); + + } + + // check the second user id + ru = CRingUser::load(_Conn, userId2, __FILE__, __LINE__); + if (ru == NULL) + { + // create a new record + ru = CRingUser::createTransient(__FILE__, __LINE__); + + ru->setUserName("invited"); +// ru->setCurrentSession(0); + + nlverify(ru->create(_Conn)); + + userId2 = ru->getObjectId(); + } + + invitedCharId = (userId2 * 16)+0; + + // check the character + character = RSMGR::CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + if (character == NULL) + { + // create a character + character = RSMGR::CCharacter::createTransient(__FILE__, __LINE__); + + character->setObjectId(invitedCharId); + character->setCharName("invited_char"); + character->setUserId(userId2); + character->setGuildId(0); + character->setBestCombatLevel(100); + + nlverify(character->create(_Conn)); + + } + + // add the tests + TEST_ADD(CCharacterSyncTS::addCharacter); + } + + ~CCharacterSyncTS() + { + // delete the session manager module + CCommandRegistry &cr = CCommandRegistry::getInstance(); + + cr.execute("moduleManager.deleteModule suc", InfoLog()); + cr.execute("moduleManager.deleteModule cs", InfoLog()); + cr.execute("moduleManager.deleteModule gw", InfoLog()); + + // remove the object created for the test + if (userId1 != 1) + { + CRingUserPtr ru = CRingUser::load(_Conn, userId1, __FILE__, __LINE__); + if (ru != NULL) + ru->remove(_Conn); + ru = CRingUser::load(_Conn, userId2, __FILE__, __LINE__); + if (ru != NULL) + ru->remove(_Conn); + + } + _Conn.closeConn(); + + CPath::setCurrentPath(OldPath.c_str()); + } + + + void addCharacter() + { + // egs create a new character in slot 0 + + uint32 newCharId = (userId1<<4)+0; + + TEST_ASSERT(IShardUnifierEvent::getInstance() != NULL); + + CCharacterPtr character = RSMGR::CCharacter::load(_Conn, newCharId, __FILE__, __LINE__); + if (character != NULL) + { + character->remove(_Conn); + character = CCharacterPtr(); + } + + CHARSYNC::TCharInfo charInfo; + charInfo.setCharEId(CEntityId(0, newCharId)); + charInfo.setBestCombatLevel(10); + charInfo.setCharName("0th character"); + IShardUnifierEvent::getInstance()->onNewChar(charInfo); + + // message dispatch will be done immediately, so the result should be cool right now + + character = RSMGR::CCharacter::load(_Conn, newCharId, __FILE__, __LINE__); + TEST_ASSERT(character != NULL); + + TEST_ASSERT(character->getBestCombatLevel() == 10); + TEST_ASSERT(character->getCharName() == "0th character"); + } + +}; + + +Test::Suite *createCCharacterSyncTS(const std::string &workingPath) +{ + return new CCharacterSyncTS(workingPath); +} diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/nope_test.cpp b/code/ryzom/tools/server/test_modules/shard_unifier_test/nope_test.cpp new file mode 100644 index 000000000..9132fb35f --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/nope_test.cpp @@ -0,0 +1,440 @@ + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/dynloadlib.h" +#include "nel/misc/path.h" +#include "nel/net/service.h" + +#include "src/cpptest.h" + +#include "game_share/mysql_wrapper.h" + +#include "test_mapping.h" + +#include +#include + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace TM; + + +class CNopeTS: public Test::Suite +{ + string _WorkingPath; +// string _BaseDir; +// string _CurrentPath; +// string _CurrentPathToRestore; + + // database connection + MSW::CConnection _Conn; + + uint32 _RootId; + +// NLMISC::CApplicationContext *_Context; + +public: + + CNopeTS(const std::string &workingPath) + { + + NLMISC::CPath::setCurrentPath((workingPath+"/test_files/shard_unifier_test").c_str()); + + // connect to the database + MYSQL *mysql; + mysql = mysql_init(NULL); + + nlverify(mysql_real_connect(mysql, "borisb2", NULL, NULL, NULL, 0,NULL,0) == mysql); + const char *error = mysql_error(mysql); + + // build the database and table needed for the test + nlverify(mysql_query(mysql, "DROP DATABASE test") == 0); + nlverify(mysql_query(mysql, "CREATE DATABASE test") == 0); + + nlverify(mysql_select_db(mysql, "test") == 0); + + + nlverify(mysql_query(mysql, "CREATE TABLE `map_child` ( \ + `Id` int(10) unsigned NOT NULL default '0',\ + `parent_id` int(10) unsigned NOT NULL default '0',\ + PRIMARY KEY (`Id`)\ + ) TYPE=MyISAM;") == 0); + nlverify(mysql_query(mysql, "CREATE TABLE `one_child` (\ + `Id` int(10) unsigned NOT NULL default '0',\ + PRIMARY KEY (`Id`)\ + ) TYPE=MyISAM;") == 0); + nlverify(mysql_query(mysql, "CREATE TABLE `root_table` (\ + `Id` int(10) unsigned NOT NULL auto_increment,\ + PRIMARY KEY (`Id`)\ + ) TYPE=MyISAM;") == 0); + nlverify(mysql_query(mysql, "CREATE TABLE `vector_child` (\ + `Id` int(10) unsigned NOT NULL default '0',\ + `parent_id` int(10) unsigned NOT NULL default '0',\ + `info` int(10) NOT NULL default '0',\ + PRIMARY KEY (`Id`)\ + ) TYPE=MyISAM;") == 0); + + + _WorkingPath = workingPath; + TEST_ADD(CNopeTS::store) + TEST_ADD(CNopeTS::load) + TEST_ADD(CNopeTS::storeOneChild) + TEST_ADD(CNopeTS::loadOneChild) + TEST_ADD(CNopeTS::badOneChild) + TEST_ADD(CNopeTS::removeOneChild) + TEST_ADD(CNopeTS::storeVectorChild) + TEST_ADD(CNopeTS::loadVectorChild) + TEST_ADD(CNopeTS::getVectorChildByIndex) + TEST_ADD(CNopeTS::removeVectorChild) + TEST_ADD(CNopeTS::storeMapChild) + TEST_ADD(CNopeTS::loadMapChild) + TEST_ADD(CNopeTS::removeMapChild) + TEST_ADD(CNopeTS::onDelete) + + } + + ~CNopeTS() + { + // terminate cleanly the embedded database server +// mysql_server_end(); + + CPath::setCurrentPath(_WorkingPath.c_str()); + +// delete _Context; + + } + + void setup() + { + NLMISC::CPath::setCurrentPath((_WorkingPath+"/test_files/shard_unifier_test").c_str()); + +// _Conn.addOption(MYSQL_READ_DEFAULT_GROUP, "libmysqld_client"); +// _Conn.addOption(MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL); + + nlassert(_Conn.connect("borisb2", "", "", "test")); + + uint32 cacheSize = NOPE::CPersistentCache::getInstance().getInstanceCount(); + } + + void tear_down() + { + _Conn.closeConn(); + + // clear the object cache + NOPE::CPersistentCache::getInstance().clearCache(); + } + + void onDelete() + { + // create a root element, then add some childs, delete the root and check the state or existence + // of child depending on 'on-delete' specified behavior + + CRootTablePtr rt = CRootTable::createTransient(__FILE__, __LINE__); + TEST_ASSERT(rt->create(_Conn)); + + uint32 rootId = rt->getObjectId(); + + CMapChildPtr mapChilds[10]; + CVectorChildPtr vectorChilds[10]; + COneChildPtr oneChild; + // create some childs + for (uint i=0; i<10; ++i) + { + mapChilds[i] = CMapChild::createTransient(__FILE__, __LINE__); + mapChilds[i]->setParentId(rootId); + mapChilds[i]->setObjectId(i+1000); + TEST_ASSERT(mapChilds[i]->create(_Conn)); + } + for (uint i=0; i<10; ++i) + { + vectorChilds[i] = CVectorChild::createTransient(__FILE__, __LINE__); + vectorChilds[i]->setParentId(rootId); + vectorChilds[i]->setObjectId(i+1000); + TEST_ASSERT(vectorChilds[i]->create(_Conn)); + } + oneChild = COneChild::createTransient(__FILE__, __LINE__); + oneChild->setObjectId(rootId); + oneChild->create(_Conn); + + // ok, now delete the root and check the childs + TEST_ASSERT(rt->remove(_Conn)); + + TEST_ASSERT(oneChild->getPersistentState() == NOPE::os_removed); + for (uint i =0; i<10; ++i) + { + TEST_ASSERT(mapChilds[i]->getObjectId() == i+1000); + TEST_ASSERT(mapChilds[i]->getPersistentState() == NOPE::os_removed); + } + for (uint i =0; i<10; ++i) + { + TEST_ASSERT(vectorChilds[i]->getObjectId() == i+1000); + TEST_ASSERT(vectorChilds[i]->getPersistentState() == NOPE::os_clean); + TEST_ASSERT(vectorChilds[i]->getParentId() == 0); + } + + + } + + void removeMapChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + TEST_ASSERT(rt->loadMapChilds(_Conn, __FILE__, __LINE__)); + + TEST_ASSERT(rt->getMapChildsById(5) != NULL); + TEST_ASSERT(rt->getMapChildsById(5)->remove(_Conn)); + + TEST_ASSERT(rt->getMapChildsById(5) == NULL); + TEST_ASSERT(rt->getMapChilds().size() == 9); + + } + + void loadMapChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + TEST_ASSERT(rt->loadMapChilds(_Conn, __FILE__, __LINE__)); + + TEST_ASSERT(rt->getMapChilds().size() == 10); + } + + void storeMapChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + rt->loadMapChilds(_Conn, __FILE__, __LINE__); + + // create 10 element in the map childs + for (uint i=0; i<10; ++i) + { + CMapChildPtr mc = CMapChild::createTransient(__FILE__, __LINE__); + + mc->setObjectId(i+1); + mc->setParentId(rt->getObjectId()); + + TEST_ASSERT(mc->create(_Conn)); + TEST_ASSERT(rt->getMapChilds().size() == i+1); + TEST_ASSERT(rt->getMapChildsById(mc->getObjectId()) == mc); + } + } + + void removeVectorChild() + { + // remove one element in the middle of the vector + + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + // load the vector childs + TEST_ASSERT(rt->loadVectorChilds(_Conn, __FILE__, __LINE__)); + + TEST_ASSERT(rt->getVectorChildsByIndex(5)->remove(_Conn)); + TEST_ASSERT(rt->getVectorChilds().size() == 9); + } + + void getVectorChildByIndex() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + // load the vector childs + TEST_ASSERT(rt->loadVectorChilds(_Conn, __FILE__, __LINE__)); + + TEST_ASSERT(rt->getVectorChildsById(15) == NULL); + TEST_ASSERT(rt->getVectorChildsById(5) != NULL); + + } + + void loadVectorChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + // load the vector childs + TEST_ASSERT(rt->loadVectorChilds(_Conn, __FILE__, __LINE__)); + + // check the number of elements + TEST_ASSERT(rt->getVectorChilds().size() == 10); + } + + void storeVectorChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + // load the vector childs (this load nothing as there are no child for now) + rt->loadVectorChilds(_Conn, __FILE__, __LINE__); + + // create some vector child + for (uint i=0; i<10; ++i) + { + CVectorChildPtr vc = CVectorChild::createTransient(__FILE__, __LINE__); + + vc->setObjectId(i+1); + vc->setParentId(rt->getObjectId()); + vc->setInfo(sint32(i)); + + TEST_ASSERT(vc->create(_Conn)); + + TEST_ASSERT(rt->getVectorChilds().size() == i+1); + TEST_ASSERT(rt->getVectorChilds().back() == vc); + } + } + + void removeOneChild() + { + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + TEST_ASSERT(rt != NULL); + // load the child + TEST_ASSERT(rt->loadOneChild(_Conn, __FILE__, __LINE__)); + + // remove the child from the persistent store + TEST_ASSERT(rt->getOneChild()->remove(_Conn)); + + // check that the parent link is updated + TEST_ASSERT(rt->getOneChild() == NULL); + } + + void badOneChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + // load the child + rt->loadOneChild(_Conn, __FILE__, __LINE__); + + // create a new one child + COneChildPtr oc = COneChild::createTransient(__FILE__, __LINE__); + oc->setObjectId(rt->getObjectId()); + + // this must fail (either during insert (if db support constraint) or after, when updating the root table) + TEST_ASSERT(oc->create(_Conn) == false); + } + + void loadOneChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + { + // load the child + COneChildPtr oc = COneChild::load(_Conn, rt->getObjectId(), __FILE__, __LINE__); + + TEST_ASSERT(oc != NULL); +// TEST_ASSERT(rt->getOneChild() == NULL); + } + + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 1); + + rt->loadOneChild(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(rt->getOneChild() != NULL); + TEST_ASSERT(rt->getOneChild()->getObjectId() == rt->getObjectId()); + + } + + void storeOneChild() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + // load the root element + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + // load the child (in fact, this load nothing because there is no child for now) + rt->loadOneChild(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(rt->getOneChild() == NULL); + + // create the one child relation element + COneChildPtr oc = COneChild::createTransient(__FILE__, __LINE__); + + oc->setObjectId(rt->getObjectId()); + + // store the element + TEST_ASSERT(oc->create(_Conn)); + + // check that the parent relation have been updated + TEST_ASSERT(rt->getOneChild() == oc) + } + + void load() + { + clearCache(); + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + + { + CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__); + + TEST_ASSERT(rt != NULL); + TEST_ASSERT(rt->getObjectId() == _RootId); + } + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 1); + + NOPE::CPersistentCache::getInstance().clearCache(); + + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + } + + void store() + { + // make sure the cache is clean + clearCache(); + + { + CRootTablePtr rt = CRootTable::createTransient(__FILE__, __LINE__); + + TEST_ASSERT(rt->create(_Conn)); + _RootId = rt->getObjectId(); + } + + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 1); + + NOPE::CPersistentCache::getInstance().clearCache(); + + TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0); + } + + void clearCache() + { + + CVectorChild::clearCache(); + NOPE::CPersistentCache::getInstance().clearCache(); + } + +}; + +Test::Suite *createCNopeTS(const std::string &workingPath) +{ + return new CNopeTS(workingPath); +} + + diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/rsm_test.cpp b/code/ryzom/tools/server/test_modules/shard_unifier_test/rsm_test.cpp new file mode 100644 index 000000000..e11585be2 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/rsm_test.cpp @@ -0,0 +1,1393 @@ +/** Test file for the ring sesison manager module */ + +#include "nel/misc/types_nl.h" +#include "nel/misc/command.h" + +#include "nel/net/module.h" +#include "nel/net/module_builder_parts.h" +#include "nel/net/module_manager.h" +#include "nel/net/unified_network.h" + +#include "src/cpptest.h" + + +#include "../../nelns/welcome_service/welcome_service_itf.h" +#include "game_share/ring_session_manager_itf.h" +#include "game_share/mysql_wrapper.h" +#include "shard_unifier_service/database_mapping.h" + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace RSMGR; +using namespace WS; + +// some globals for the test +TSessionId sessionId(0); + +uint32 userId = 1; +uint32 charId = (userId*16)+0; + +uint32 invitedUserId = 2; +uint32 invitedCharId = (invitedUserId*16)+0; + +uint32 subscriberUserId = 3; +uint32 subscriberCharId = (subscriberUserId*16)+0; + +uint32 guildId = 1; + +// place holder module for welcome service +class CPHWelcomeServiceModule : + public CEmptyModuleServiceBehav > >, + public CWelcomeServiceSkel +{ +public: + CPHWelcomeServiceModule () + { + CWelcomeServiceSkel::init(this); + } + +// void onProcessModuleMessage(IModuleProxy *sender, const CMessage &message) +// { +// nlverify(CWelcomeServiceSkel::onDispatchMessage(sender, message)); +// } + + // ask the welcome service to welcome a user + void welcomeUser(NLNET::IModuleProxy *sender, + uint32 charId, + const std::string &userName, + const NLNET::CLoginCookie &cookie, + const std::string &priviledge, + const std::string &exPriviledge, + WS::TUserRole mode, + uint32 instanceId) + { + CWelcomeServiceClientProxy client(sender); + client.welcomeUserResult(this, charId>>4, true, "localhost", ""); + } + // ask the welcome service to disconnect a user + void disconnectUser(NLNET::IModuleProxy *sender, uint32 userId) + { + } + + void onModuleUp(IModuleProxy *module) + { + if (module->getModuleClassName() == "RingSessionManager") + { + CWelcomeServiceClientProxy client(module); + // register against the session manager + client.registerWS(this, 1, 0, true); + } + } + +}; + +NLNET_REGISTER_MODULE_FACTORY(CPHWelcomeServiceModule, "WelcomeService"); + + +// place holder module for server edition module +class CPHServerEditionModule : + public CEmptyModuleServiceBehav > >, + public CRingSessionManagerClientSkel +{ + TModuleProxyPtr _SessionManager; +public: + + // a set of kick reported to DSS by RSM + set KickedChars; + + CPHServerEditionModule() + { + CRingSessionManagerClientSkel::init(this); + } + +// void onProcessModuleMessage(IModuleProxy *sender, const CMessage &message) +// { +// nlverify(CRingSessionManagerClientSkel::onDispatchMessage(sender, message)); +// } + + void onModuleUp(IModuleProxy *module) + { + if (module->getModuleClassName() == "RingSessionManager") + { + CRingSessionManagerProxy rsm(module); + // register against the session manager + std::vector < TRunningSessionInfo > runningSession; + rsm.registerDSS(this, 1, runningSession); + + _SessionManager = module; + } + } + + void onModuleDown(IModuleProxy *module) + { + if (module == _SessionManager) + { + _SessionManager = NULL; + } + } + + // Ask the client to create a new session modules + virtual void createSession(NLNET::IModuleProxy *sender, uint32 ownerCharId, TSessionId sessionId, RSMGR::TSessionType type) + { + // the shard unifier ask to start a session, be fair with him + CRingSessionManagerProxy rsm(sender); + + TRunningSessionInfo rsi; + rsi.setInstanceId(sessionId); + rsi.setNbPlayingChars(0); + rsi.setSessionId(sessionId); + + rsm.sessionCreated(this, rsi); + + } + + // Ask the client allow a helper character in the session + virtual void addCharacterInSession(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 charId, WS::TUserRole enterAs, const std::string &ringAccess, bool newcomer) +// virtual void addCharacterInSession(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 charId, WS::TUserRole enterAs) + { + + } + // Ask the client to close a running session + virtual void closeSession(NLNET::IModuleProxy *sender, TSessionId sessionId) + { + } + + void characterKicked(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 charId) + { + KickedChars.insert(charId); + } + + virtual void teleportOneCharacterToAnother(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 sourceCharId, uint32 destCharId) + { + } + + + // we ask to the rsm to kick a character + void kickACharacter(TSessionId sessionId, uint32 charId) + { + nlassert(_SessionManager != NULL); + + // send a kick report to the session manager + CRingSessionManagerProxy rsm(_SessionManager); + + rsm.reportCharacterKicked(this, sessionId, charId); + } + + // Ask the client to create a new session modules + virtual void createSession(NLNET::IModuleProxy *sender, uint32 ownerCharId, TSessionId sessionId, const RSMGR::TSessionType &type) + { + nlstop; + } + // Ask the client to allow a character in the session + virtual void addCharacterInSession(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 charId, const WS::TUserRole &enterAs, const std::string &ringAccess, bool newcomer) + { + nlstop; + } + // Ask the client stop hibernation for the + // specified session. This mean to remove any + // hibernated scenario file from the backup. + virtual void stopHibernation(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 ownerId) + { + nlstop; + } + // Session mananger report that a character has been unkicked by the web + virtual void characterUnkicked(NLNET::IModuleProxy *sender, TSessionId sessionId, uint32 charId) + { + nlstop; + } + // Ask to hibernate a session + virtual void hibernateSession(NLNET::IModuleProxy *sender, TSessionId sessionId) + { + nlstop; + } + // Set the start position of a session (eg while your are uploading an animation session) + virtual void setSessionStartParams(NLNET::IModuleProxy *sender, uint32 charId, TSessionId sessionId, const std::string &initialIslandLocation, const std::string &initialEntryPointLocation, const std::string &initialSeason) + { + nlstop; + } + + +}; + +NLNET_REGISTER_MODULE_FACTORY(CPHServerEditionModule, "ServerEditionModule"); + +/** place holder class for the web communication */ +class CPHWeb : public RSMGR::CRingSessionManagerWebClientItf +{ +public: + + vector LastResults; + + uint32 LastSession; + + /// Disconnection callback : the connection to the server is lost + virtual void on_CRingSessionManagerWebClient_Disconnection(NLNET::TSockId from) + { + } + + + // Generic response to invoke. + // result contains 0 if no error, more than 0 in case of error + virtual void on_invokeResult(NLNET::TSockId from, uint32 userId, uint32 resultCode, const std::string &resultString) + { + LastResults.push_back(resultCode); + } + + // result is : 0 : session have been created fine + // 1 : invalid session type + // 2 : invalid level + // 3 : unknown user + // 4 : not used + // 5 : invalid access type + // 6 : invalid rule type + // 7 : invalid duration + virtual void on_scheduleSessionResult(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint8 result, const std::string &resultString) +// virtual void on_scheduleSessionResult(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint8 result) + { + LastResults.push_back(result); + LastSession = sessionId; + } + + // session info result (anim) + virtual void on_sessionInfoResult(NLNET::TSockId from, uint32 charId, TSessionId sessionId, const TRaceFilter &raceFilter, const TReligionFilter &religionFilter, const TGuildFilter &guildFilter, const TShardFilter &shardFilter, const TLevelFilter &levelFilter, bool subscriptionClosed, bool autoInvite, const std::string &language, const TSessionOrientation &orientation, const std::string &description) + { + + } + + // Return the result of the session joining attempt + // If join is ok, the shardAddr contain of the + // Front end that waits for the player to come in and the. + // participation mode for the character (editor, animator or player). + // If ok, the web must return a page with a lua script. + // that trigger the action handler 'on_connect_to_shard' : + // runAH(nul, "on_connect_to_shard", "cookie=cookieValue|fsAddr=shardAddr|mode=participantStatus"); + // result : 0 : ok the client can join the session + // 1 : char not found + // 2 : session not found + // 3 : no session participant for this character (not used for a mainland shard) + // 4 : can't find session server (not used for a mainland shard) + // 5 : shard hosting session is not reachable + // 6 : nel user info not found + // 7 : ring user not found + // 8 : welcome service rejected connection request + // 9 : session service shutdown (not used for a mainland shard) + // 10 : no mainland shard found (joinMainland only) + // 11 : internal error + // 12 : failed to request for access permission + // 13 : can't find access permission for user and domain + // 14 : Welcome service is closed for you + // 15 : Session is not open + // 16 : User banned from ring + // 17 : Newcomer flag missmatch + // 18 : Can't find session log to validate session access + // 19 : Can't find scenario info to validate session access + // 20 : Scenario is not allowed to free trial players + virtual void on_joinSessionResult(NLNET::TSockId from, uint32 userId, TSessionId sessionId, uint32 result, const std::string &shardAddr, const TSessionPartStatus &participantStatus) + { + LastResults.push_back(result); + } + + // See joinSessionResult. + // Adds a security code. + virtual void on_joinSessionResultExt(NLNET::TSockId from, uint32 userId, TSessionId sessionId, uint32 result, const std::string &shardAddr, const TSessionPartStatus &participantStatus, const CSecurityCode &securityCheckForFastDisconnection) + { + nlstop; + } + + // Return the list of online shards on which the user is allowed to connect, + // and their current dynamic attributes. Other attributes (e.g. names) + // can be queried from the database. Offline shards are the ones in the database + // of the same domain but not listed in the result. + // Then the client will have to call joinShard to connect on an online shard. + virtual void on_getShardsResult(NLNET::TSockId from, uint32 userId, const std::string &result) + { + nlstop; + } + + +}; + + + +class CRSMTS: public Test::Suite +{ + MSW::CConnection _Conn; + + CPHServerEditionModule *ServerEditionModule; + +public: + CRSMTS(const std::string &workingPath) + { + ServerEditionModule = NULL; + + // force instanciation of the module manager + IModuleManager::getInstance(); + // create the session manager module + CCommandRegistry &cr = CCommandRegistry::getInstance(); + + string DBHost = "borisb2"; + + cr.execute("moduleManager.createModule StandardGateway gw", InfoLog()); + cr.execute(string()+"moduleManager.createModule RingSessionManager rsm web(port=49999) ring_db(host="+DBHost+" user=root password base=ring) nel_db(host="+DBHost+" user=root password base=nel) noPerm", InfoLog()); + cr.execute("rsm.plug gw", InfoLog()); + cr.execute("moduleManager.createModule ServerEditionModule sam", InfoLog()); + cr.execute("sam.plug gw", InfoLog()); + + cr.execute("moduleManager.createModule WelcomeService ws", InfoLog()); + cr.execute("ws.plug gw", InfoLog()); + + + // check database population + nlverify(_Conn.connect(DBHost, "root", "", "ring")); + + // check the user id + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + if (ru == NULL) + { + // create a new record + ru = CRingUser::createTransient(__FILE__, __LINE__); + + ru->setUserName("toto"); +// ru->setCurrentSession(0); + + nlverify(ru->create(_Conn)); + + userId = ru->getObjectId(); + } + else + { +// ru->setCurrentSession(0); + ru->update(_Conn); + } + + + charId = (userId * 16)+0; + + // check the character + CCharacterPtr character = CCharacter::load(_Conn, charId, __FILE__, __LINE__); + if (character == NULL) + { + // create a character + character = CCharacter::createTransient(__FILE__, __LINE__); + + character->setObjectId(charId); + character->setCharName("toto_char"); + character->setUserId(userId); + character->setGuildId(0); + character->setBestCombatLevel(100); + + nlverify(character->create(_Conn)); + + } + + // check the invited user id + ru = CRingUser::load(_Conn, invitedUserId, __FILE__, __LINE__); + if (ru == NULL) + { + // create a new record + ru = CRingUser::createTransient(__FILE__, __LINE__); + + ru->setUserName("invited"); +// ru->setCurrentSession(0); + + nlverify(ru->create(_Conn)); + + invitedUserId = ru->getObjectId(); + } + else + { +// ru->setCurrentSession(0); + ru->update(_Conn); + } + + // check the subscriber user id + ru = CRingUser::load(_Conn, subscriberUserId, __FILE__, __LINE__); + if (ru == NULL) + { + // create a new record + ru = CRingUser::createTransient(__FILE__, __LINE__); + + ru->setUserName("subscriber"); +// ru->setCurrentSession(0); + + nlverify(ru->create(_Conn)); + + invitedUserId = ru->getObjectId(); + } + else + { +// ru->setCurrentSession(0); + ru->update(_Conn); + } + + + invitedCharId = (invitedUserId * 16)+0; + + // check the character + character = CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + if (character == NULL) + { + // create a character + character = CCharacter::createTransient(__FILE__, __LINE__); + + character->setObjectId(invitedCharId); + character->setCharName("invited_char"); + character->setUserId(invitedUserId); + character->setGuildId(0); + character->setBestCombatLevel(100); + + nlverify(character->create(_Conn)); + + } + + // check the character + subscriberCharId = (subscriberUserId * 16)+0; + character = CCharacter::load(_Conn, subscriberCharId, __FILE__, __LINE__); + if (character == NULL) + { + // create a character + character = CCharacter::createTransient(__FILE__, __LINE__); + + character->setObjectId(subscriberCharId); + character->setCharName("subscriber_char"); + character->setUserId(subscriberUserId); + character->setGuildId(0); + character->setBestCombatLevel(100); + + nlverify(character->create(_Conn)); + } + + + // check the guild used for the test + CGuildPtr guild = CGuild::load(_Conn, guildId, __FILE__, __LINE__); + if (guild == 0) + { + // create guild + guild = CGuild::createTransient(__FILE__, __LINE__); + guild->setGuildName("A test guild"); + guild->setObjectId(guildId); + nlverify(guild->create(_Conn)); + } + + // add the tests + TEST_ADD(CRSMTS::scheduleSession); + TEST_ADD(CRSMTS::inviteChar); + TEST_ADD(CRSMTS::startSession); + TEST_ADD(CRSMTS::removeInvitedCharacter); + TEST_ADD(CRSMTS::joinSession); + TEST_ADD(CRSMTS::updateSessionInfo); + TEST_ADD(CRSMTS::subscribeInSession); + TEST_ADD(CRSMTS::unsubscribeInSession); + TEST_ADD(CRSMTS::inviteGuild); + TEST_ADD(CRSMTS::kickCharacterWithDSS); + TEST_ADD(CRSMTS::unkickCharacter); + TEST_ADD(CRSMTS::kickCharacterWithWeb); + + TEST_ADD(CRSMTS::cancelSession); + TEST_ADD(CRSMTS::closeSession); + TEST_ADD(CRSMTS::addFriendCharacter); + TEST_ADD(CRSMTS::setKnownUserComment); + TEST_ADD(CRSMTS::removeFriendCharacter); + TEST_ADD(CRSMTS::addBannedCharacter); + TEST_ADD(CRSMTS::removeBannedCharacter); + TEST_ADD(CRSMTS::addJournalEntry); + TEST_ADD(CRSMTS::setPlayerRating); + + + TEST_ADD(CRSMTS::dssDown); + + + } + + ~CRSMTS() + { + // delete the session manager module + CCommandRegistry &cr = CCommandRegistry::getInstance(); + + cr.execute("moduleManager.deleteModule rsm", InfoLog()); + cr.execute("moduleManager.deleteModule sam", InfoLog()); + cr.execute("moduleManager.deleteModule gw", InfoLog()); + + // remove the object created for the test + if (userId != 1) + { + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + if (ru != NULL) + ru->remove(_Conn); + ru = CRingUser::load(_Conn, invitedUserId, __FILE__, __LINE__); + if (ru != NULL) + ru->remove(_Conn); + ru = CRingUser::load(_Conn, subscriberUserId, __FILE__, __LINE__); + if (ru != NULL) + ru->remove(_Conn); + + CGuildPtr guild = CGuild::load(_Conn, guildId, __FILE__, __LINE__); + if (guild != NULL) + guild->remove(_Conn); + } + _Conn.closeConn(); + + ServerEditionModule = NULL; + } + + void dssDown() + { + // this test validate the correction for the dss down rsm crash + + // unplug the dss and see what happen (normaly nothing) + CCommandRegistry &cr = CCommandRegistry::getInstance(); + cr.execute("moduleManager.deleteModule sam", InfoLog()); + + } + + void setup() + { + ServerEditionModule = dynamic_cast(IModuleManager::getInstance().getLocalModule("sam")); + } + + void tear_down() + { + ServerEditionModule = NULL; + } + + void setPlayerRating() + { + // TODO : update this code +// TEST_ASSERT(userId != 0); +// TEST_ASSERT(charId != 0); +// TEST_ASSERT(sessionId != 0); +// +// // add an entry in the session journal +// +// CPHWeb web; +// web.connectItf(NLNET::CInetAddress("localhost", 49999)); +// +// // 1st, cleanup the session ratings +// CSessionPtr session = CSession::load(_Conn, sessionId, __FILE__, __LINE__); +// TEST_ASSERT(session != NULL); +// TEST_ASSERT(session->loadPlayerRatings(_Conn, __FILE__, __LINE__)); +// while (!session->getPlayerRatings().empty()) +// { +// TEST_ASSERT(session->getPlayerRatingsByIndex(session->getPlayerRatings().size()-1)->remove(_Conn)); +// } +// // then close the session +// session->setState(TSessionState::ss_closed); +// session->update(_Conn); +// +// // add the journal entry +// web.setPlayerRating(charId, sessionId, 2, "a rating comment"); +// +// updateNetwork(web); +// +// TEST_ASSERT(web.LastResults.size() == 1); +// TEST_ASSERT(web.LastResults.back() == 0); +// +// // chek the session +// TEST_ASSERT(session->getPlayerRatings().size() == 1); +// CPlayerRatingPtr pr = session->getPlayerRatingsByIndex(0); +// TEST_ASSERT(pr->getAuthor() == charId); +// TEST_ASSERT(pr->getRating() == 2); +// TEST_ASSERT(pr->getComments() == "a rating comment"); + } + + void addJournalEntry() + { + TEST_ASSERT(userId != 0); + TEST_ASSERT(charId != 0); + TEST_ASSERT(sessionId != 0); + + // add an entry in the session journal + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // 1st, cleanup the session journal + CSessionPtr session = CSession::load(_Conn, sessionId, __FILE__, __LINE__); + TEST_ASSERT(session != NULL); + TEST_ASSERT(session->loadJournalEntries(_Conn, __FILE__, __LINE__)); + while (!session->getJournalEntries().empty()) + { + TEST_ASSERT(session->getJournalEntriesByIndex(session->getJournalEntries().size()-1)->remove(_Conn)); + } + // set the character in 'sps_animatig' mode in the session + TEST_ASSERT(session->loadSessionParticipants(_Conn, __FILE__, __LINE__)); + uint i=0; + for (uint i=0; igetSessionParticipants().size(); ++i) + { + if (session->getSessionParticipantsByIndex(i)->getCharId() == charId) + { + // we found the participation, update it + session->getSessionParticipantsByIndex(i)->setStatus(TSessionPartStatus::sps_animating); + + session->getSessionParticipantsByIndex(i)->update(_Conn); + } + } + + // add the journal entry + web.addJournalEntry(charId, sessionId, "jet_credits", "a journal credits text"); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + // check the session + TEST_ASSERT(session->getJournalEntries().size() == 1); + CJournalEntryPtr je = session->getJournalEntriesByIndex(0); + TEST_ASSERT(je->getType() == TJournalEntryType::jet_credits); + TEST_ASSERT(je->getAuthor() == charId); + TEST_ASSERT(je->getText() == "a journal credits text"); + } + + void removeBannedCharacter() + { + TEST_ASSERT(userId != 0); + TEST_ASSERT(invitedCharId != 0); + // add a friend char to the user (need the previous test to have worked) + + // 1st, load the user and clean the friend list + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + TEST_ASSERT(ru != NULL); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + const vector &kus = ru->getKnownUsers(); + + // check starting state + TEST_ASSERT(ru->getKnownUsers().size() == 1); + TEST_ASSERT(ru->getKnownUsersByIndex(0)->getTargetCharacter() == invitedCharId); + + // clear the cache + ru = CRingUserPtr(); + NOPE::CPersistentCache::getInstance().clearCache(); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // add the friend + web.removeBannedCharacter(userId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(ru->getKnownUsers().size() == 0); + } + + + void addBannedCharacter() + { + TEST_ASSERT(userId != 0); + TEST_ASSERT(invitedCharId != 0); + // add a friend char to the user (need the previous test to have worked) + + // 1st, load the user and clean the friend list + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + TEST_ASSERT(ru != NULL); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + const vector &kus = ru->getKnownUsers(); + + // check starting state + TEST_ASSERT(ru->getKnownUsers().size() == 0); + + // clear the cache + ru = CRingUserPtr(); + NOPE::CPersistentCache::getInstance().clearCache(); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // add the friend + web.addBannedCharacter(userId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(ru->getKnownUsers().size() == 1); + TEST_ASSERT(ru->getKnownUsersByIndex(0)->getTargetCharacter() == invitedCharId); + TEST_ASSERT(ru->getKnownUsersByIndex(0)->getRelation() == TKnownUserRelation::rt_banned); + } + + void removeFriendCharacter() + { + TEST_ASSERT(userId != 0); + TEST_ASSERT(invitedCharId != 0); + // add a friend char to the user (need the previus test to have worked) + + // 1st, load the user and clean the friend list + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + TEST_ASSERT(ru != NULL); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + const vector &kus = ru->getKnownUsers(); + + // check starting state + TEST_ASSERT(ru->getKnownUsers().size() == 1); + TEST_ASSERT(ru->getKnownUsersByIndex(0)->getTargetCharacter() == invitedCharId); + + // clear the cache + ru = CRingUserPtr(); + NOPE::CPersistentCache::getInstance().clearCache(); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // add the friend + web.removeFriendCharacter(userId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(ru->getKnownUsers().size() == 0); + } + + void setKnownUserComment() + { + // set a comment on a known user + + // 1st, load the user and clean the comment (if any) + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + TEST_ASSERT(ru != NULL); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + const vector &kus = ru->getKnownUsers(); + + // loop until we found the know user we are looking for + for (uint i=0; igetKnownUsersByIndex(i); + + TEST_ASSERT(ku != NULL); + + if (ku->getTargetCharacter() == invitedCharId) + { + // ok, it's this one + ku->setComments(""); + break; + } + } + + // create the web caller + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // set the comment + web.setKnownCharacterComments(userId, invitedCharId, "rt_friend", "the comment"); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + TEST_ASSERT(ru != NULL); + TEST_ASSERT(ru->loadKnownUsers(_Conn, __FILE__, __LINE__)); + + // look for the friend + for (uint i=0; igetKnownUsers().size(); ++i) + { + CKnownUserPtr ku = ru->getKnownUsersByIndex(i); + if (ku->getTargetCharacter() == invitedCharId) + { + TEST_ASSERT(ku->getComments() == "the comment"); + break; + } + } + } + + void addFriendCharacter() + { + TEST_ASSERT(userId != 0); + TEST_ASSERT(invitedCharId != 0); + // add a friend char to the user + + // 1st, load the user and clean the friend list + CRingUserPtr ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + TEST_ASSERT(ru != NULL); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + const vector &kus = ru->getKnownUsers(); + + // loop until container is empty + while (!kus.empty()) + { + CKnownUserPtr ku = ru->getKnownUsersByIndex(kus.size() -1); + + // remove this one + ku->remove(_Conn); + } + + // clear the cache + ru = CRingUserPtr(); + NOPE::CPersistentCache::getInstance().clearCache(); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // add the friend + web.addFriendCharacter(userId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + ru = CRingUser::load(_Conn, userId, __FILE__, __LINE__); + ru->loadKnownUsers(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(ru->getKnownUsers().size() == 1); + TEST_ASSERT(ru->getKnownUsersByIndex(0)->getTargetCharacter() == invitedCharId); + TEST_ASSERT(ru->getKnownUsersByIndex(0)->getRelation() == TKnownUserRelation::rt_friend); + + } + + void closeSession() + { + TEST_ASSERT(sessionId != 0); + // close a running session + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.closeSession(charId, sessionId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + } + + void cancelSession() + { + // try to cancel the session + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // ask to create an editing session + web.scheduleSession( + charId, + TSessionType::st_edit, + "Session Title", +// NLMISC::CTime::getSecondsSince1970(), + "Session Description", + R2::TSessionLevel::sl_a, +// TAccessType::at_public, + TRuleType::rt_liberal, + TEstimatedDuration::et_medium, + 0, + TAnimMode::am_dm, + TRaceFilter(TRaceFilterEnum::rf_fyros), + TReligionFilter(TReligionFilterEnum::rf_kami), + TGuildFilter::gf_any_player, + TShardFilter(TShardFilterEnum::sf_shard00), + TLevelFilter(TLevelFilterEnum::lf_a), + "fr", + TSessionOrientation::so_other, + false, + true); + + // update the network + updateNetwork(web); + + TSessionId sessionId = web.LastSession; + + web.cancelSession(charId, sessionId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 2); + TEST_ASSERT(web.LastResults.back() == 0); + + // ask to create an animation session + web.scheduleSession( + charId, + TSessionType::st_anim, + "Session Title", +// NLMISC::CTime::getSecondsSince1970(), + "Session Description", + R2::TSessionLevel::sl_a, +// TAccessType::at_public, + TRuleType::rt_liberal, + TEstimatedDuration::et_medium, + 0, + TAnimMode::am_dm, + TRaceFilter(TRaceFilterEnum::rf_fyros), + TReligionFilter(TReligionFilterEnum::rf_kami), + TGuildFilter::gf_any_player, + TShardFilter(TShardFilterEnum::sf_shard00), + TLevelFilter(TLevelFilterEnum::lf_a), + "fr", + TSessionOrientation::so_other, + false, + true); + + + // update the network + updateNetwork(web); + + sessionId = web.LastSession; + + web.cancelSession(charId, sessionId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 4); + TEST_ASSERT(web.LastResults.back() == 0); + + + } + + void removeInvitedGuild() + { + TEST_ASSERT(sessionId != 0); + TEST_ASSERT(guildId != 0); + + // cleanup the invitation + CGuildPtr guild = CGuild::load(_Conn, guildId, __FILE__, __LINE__); + TEST_ASSERT(guild != NULL); + guild->loadInvites(_Conn, __FILE__, __LINE__); + + TEST_ASSERT(guild->getInvites().size() == 1); + TEST_ASSERT(guild->getInvites().back()->getSessionId() == sessionId); + + // invite a guild in the session + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.removeInvitedGuild(charId, sessionId, guildId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + TEST_ASSERT(guild->getInvites().size() == 0); + } + + void kickCharacterWithWeb() + { + TEST_ASSERT(sessionId != 0); + TEST_ASSERT(ServerEditionModule != NULL); + TEST_ASSERT(invitedCharId != 0); + + CCharacterPtr character = CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + TEST_ASSERT(character != NULL); + + TEST_ASSERT(character->loadSessionParticipants(_Conn, __FILE__, __LINE__)); + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getKicked() == false); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.kickCharacter(charId, sessionId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getKicked() == true); + + TEST_ASSERT(ServerEditionModule->KickedChars.find(invitedCharId) != ServerEditionModule->KickedChars.end()); + } + + + void unkickCharacter() + { + TEST_ASSERT(sessionId != 0); + TEST_ASSERT(ServerEditionModule != NULL); + TEST_ASSERT(invitedCharId != 0); + + CCharacterPtr character = CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + TEST_ASSERT(character != NULL); + + TEST_ASSERT(character->loadSessionParticipants(_Conn, __FILE__, __LINE__)); + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getKicked() == true); + + ServerEditionModule->KickedChars.clear(); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.unkickCharacter(charId, sessionId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getKicked() == false); + + TEST_ASSERT(ServerEditionModule->KickedChars.empty()); + } + + + void kickCharacterWithDSS() + { + TEST_ASSERT(sessionId != 0); + TEST_ASSERT(ServerEditionModule != NULL); + TEST_ASSERT(invitedCharId != 0); + + CCharacterPtr character = CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + TEST_ASSERT(character != NULL); + + TEST_ASSERT(character->loadSessionParticipants(_Conn, __FILE__, __LINE__)); + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getKicked() == false); + + // kick a character from the session from DSS + ServerEditionModule->kickACharacter(sessionId, invitedCharId); + + for (uint i=0; i<10; ++i) + { + IModuleManager::getInstance().updateModules(); + + nlSleep(10); + } + + + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getKicked() == true); + } + + void inviteGuild() + { + TEST_ASSERT(sessionId != 0); + TEST_ASSERT(guildId != 0); + + // cleanup the invitation + CGuildPtr guild = CGuild::load(_Conn, guildId, __FILE__, __LINE__); + TEST_ASSERT(guild != NULL); + guild->loadInvites(_Conn, __FILE__, __LINE__); + while (!guild->getInvites().empty()) + { + guild->getInvitesByIndex(guild->getInvites().size()-1)->remove(_Conn); + } + + // invite a guild in the session + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.inviteGuild(charId, sessionId, guildId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + guild = CGuild::load(_Conn, guildId, __FILE__, __LINE__); + TEST_ASSERT(guild != NULL); + guild->loadInvites(_Conn, __FILE__, __LINE__); + TEST_ASSERT(guild->getInvites().size() == 1); + TEST_ASSERT(guild->getInvites().back()->getSessionId() == sessionId); + } + + void unsubscribeInSession() + { + // try to unsubscribe a character from a session + TEST_ASSERT(sessionId != 0); + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // unsubscribe from the session + web.unsubscribeSession(subscriberCharId, sessionId); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + // check the subscribed slot count + CSessionPtr session = CSession::load(_Conn, sessionId, __FILE__, __LINE__); + TEST_ASSERT(session != NULL); + TEST_ASSERT(session->getSubscriptionSlots() == 5); + TEST_ASSERT(session->getReservedSlots() == 0); + + // check the invitation + TEST_ASSERT(session->loadSessionParticipants(_Conn, __FILE__, __LINE__)); + const vector &parts = session->getSessionParticipants(); + uint i; + for (i=0; igetCharId() == subscriberCharId) + break; + } + TEST_ASSERT(i == parts.size()); + } + void subscribeInSession() + { + // try to subscribe a character in a session + TEST_ASSERT(sessionId != 0); + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // subscribe in the session, must fail because no slot available + web.subscribeSession(subscriberCharId, sessionId); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 6); + + // update the session info, allowing some place for subscriber + web.updateSessionInfo(charId, + sessionId, + "updated title", + NLMISC::CTime::getSecondsSince1970()+24*12*60*60, + "updated description", + R2::TSessionLevel::sl_b, +// TAccessType::at_public, + TEstimatedDuration::et_long, + 5, + TRaceFilter(TRaceFilterEnum::rf_fyros), + TReligionFilter(TReligionFilterEnum::rf_kami), + TGuildFilter::gf_any_player, + TShardFilter(TShardFilterEnum::sf_shard00), + TLevelFilter(TLevelFilterEnum::lf_a), + false, + true, + "fr", + TSessionOrientation::so_other); + + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 2); + TEST_ASSERT(web.LastResults.back() == 0); + + // retry to subscribe in the session + web.subscribeSession(subscriberCharId, sessionId); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 3); + TEST_ASSERT(web.LastResults.back() == 0); + + // check the subscribed slot count + CSessionPtr session = CSession::load(_Conn, sessionId, __FILE__, __LINE__); + TEST_ASSERT(session != NULL); + TEST_ASSERT(session->getSubscriptionSlots() == 5); + TEST_ASSERT(session->getReservedSlots() == 1); + + // check the invitation + TEST_ASSERT(session->loadSessionParticipants(_Conn, __FILE__, __LINE__)); + const vector &parts = session->getSessionParticipants(); + uint i; + for (i=0; igetCharId() == subscriberCharId) + break; + } + TEST_ASSERT(i != parts.size()); + + } + + void updateSessionInfo() + { + TEST_ASSERT(sessionId != 0); + // try to update the session info + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.updateSessionInfo(charId, + sessionId, + "updated title", + NLMISC::CTime::getSecondsSince1970()+24*12*60*60, + "updated description", + R2::TSessionLevel::sl_b, +// TAccessType::at_public, + TEstimatedDuration::et_long, + 0, + TRaceFilter(TRaceFilterEnum::rf_fyros), + TReligionFilter(TReligionFilterEnum::rf_kami), + TGuildFilter::gf_any_player, + TShardFilter(TShardFilterEnum::sf_shard00), + TLevelFilter(TLevelFilterEnum::lf_a), + false, + true, + "fr", + TSessionOrientation::so_other); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + } + + void joinSession() + { + TEST_ASSERT(sessionId != 0); + // try to join the session with the two character + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // join for the first character + web.joinSession(charId, sessionId, "borisb2"); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + // re-invite the second character + web.inviteCharacter(charId, sessionId, invitedCharId, TSessionPartStatus(TSessionPartStatus::sps_edit_invited).toString()); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 2); + TEST_ASSERT(web.LastResults.back() == 0); + + + // join for the second character + web.joinSession(invitedCharId, sessionId, "borisb2"); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 3); + TEST_ASSERT(web.LastResults.back() == 0); + } + + void removeInvitedCharacter() + { + TEST_ASSERT(sessionId != 0); + + // remove the invitation for a character + CCharacterPtr character = CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + TEST_ASSERT(character != NULL); + + character->loadSessionParticipants(_Conn, __FILE__, __LINE__); + TEST_ASSERT(character->getSessionParticipants().size() == 1); + TEST_ASSERT(character->getSessionParticipantsByIndex(0)->getSessionId() == sessionId); + + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.removeInvitedCharacter(charId, sessionId, invitedCharId); + + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + TEST_ASSERT(character->getSessionParticipants().size() == 0); + } + + + void startSession() + { + TEST_ASSERT(sessionId != 0); + // start a session + CPHWeb web; + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.startSession(charId, sessionId); + + updateNetwork(web); + + // check the result + TEST_ASSERT(!web.LastResults.empty()); + TEST_ASSERT(web.LastResults.back() == 0); + } + + void inviteChar() + { + TEST_ASSERT(sessionId != 0); + // invite a character in a scheduled session + CPHWeb web; + + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + web.inviteCharacter(charId, sessionId, charId, TSessionPartStatus(TSessionPartStatus::sps_edit_invited).toString()); + // update the network + updateNetwork(web); + + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + // cleanup the database for other test + CCharacterPtr character = CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__); + TEST_ASSERT(character != NULL); + + character->loadSessionParticipants(_Conn, __FILE__, __LINE__); + // delete any existing participation + + while (!character->getSessionParticipants().empty()) + { + character->getSessionParticipantsByIndex(character->getSessionParticipants().size()-1)->remove(_Conn); + } + + // invite for the second character + web.inviteCharacter(charId, sessionId, invitedCharId, TSessionPartStatus(TSessionPartStatus::sps_edit_invited).toString()); + updateNetwork(web); + // check the result + TEST_ASSERT(web.LastResults.size() == 2); + TEST_ASSERT(web.LastResults.back() == 0); + } + + void scheduleSession() + { + // schedule a session from the web + CPHWeb web; + + // connect the web to the session manager module + web.connectItf(NLNET::CInetAddress("localhost", 49999)); + + // ask to create a session + web.scheduleSession( + charId, + TSessionType::st_edit, + "Session Title", +// NLMISC::CTime::getSecondsSince1970(), + "Session Description", + R2::TSessionLevel::sl_a, +// TAccessType::at_public, + TRuleType::rt_liberal, + TEstimatedDuration::et_medium, + 0, + TAnimMode::am_dm, + TRaceFilter(TRaceFilterEnum::rf_fyros), + TReligionFilter(TReligionFilterEnum::rf_kami), + TGuildFilter::gf_any_player, + TShardFilter(TShardFilterEnum::sf_shard00), + TLevelFilter(TLevelFilterEnum::lf_a), + "fr", + TSessionOrientation::so_other, + false, + true); + + + // update the network + updateNetwork(web); + + // check that the session have been scheduled + TEST_ASSERT(web.LastResults.size() == 1); + TEST_ASSERT(web.LastResults.back() == 0); + + // store the session ID for later + sessionId = web.LastSession; + } + + void updateNetwork(CPHWeb &web) + { + for (uint i=0; i<10; ++i) + { + web.update(); + IModuleManager::getInstance().updateModules(); + + nlSleep(10); + } + } + +}; + + +Test::Suite *createCRSMTS(const std::string &workingPath) +{ + return new CRSMTS(workingPath); +} diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/shard_unifier_test.cpp b/code/ryzom/tools/server/test_modules/shard_unifier_test/shard_unifier_test.cpp new file mode 100644 index 000000000..8f566bf6f --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/shard_unifier_test.cpp @@ -0,0 +1,190 @@ + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/dynloadlib.h" +#include "nel/misc/path.h" +#include "nel/net/service.h" + +#include "src/cpptest.h" + +//#include "pd_lib/pd_string_manager.h" +#include "game_share/mysql_wrapper.h" + +#include "entities_game_service/guild_manager/guild_manager_interface.h" +#include "entities_game_service/guild_manager/guild_interface.h" + +#include "test_mapping.h" + +#include +#include + +using namespace std; +using namespace NLMISC; +using namespace NLNET; + +class CGuildManagerPH : public IGuildManager +{ + virtual void guildMemberChanged (EGSPD::CGuildMemberPD *guildMemberPd) + { + nlstop; + } + /// the member list has been changed (ether add/replace or delete) + virtual void guildMemberListChanged (EGSPD::CGuildPD *guildPd) + { + nlstop; + } + virtual void updateGuildMembersStringIds() + { +// nlstop; + } + virtual void createGuildStep2 (uint32 guildId, const ucstring &guildName, CHARSYNC::TCharacterNameResult result) + { + nlstop; + } + + virtual CGuild *getGuildFromId (uint32 guildId) + { + nlstop; + return NULL; + } + virtual void addGuildsAwaitingString ( const ucstring & guildStr, uint32 guildId ) + { + nlstop; + } + + /// get raw access to the guild list (not const) + virtual const EGSPD::CGuildContainerPD *getGuildContainer() const + { + nlstop; + return NULL; + } + + /// A player entity have been removed from eid translator, check all guild member list + virtual void playerEntityRemoved(const NLMISC::CEntityId &eid) + { + nlstop; + } + /// check if guilds have been loaded + virtual bool guildLoaded() + { + return true; + } + + /// fill a list with all guild descriptors + virtual void fillGuildInfos(std::vector &guildInfos) + { +// nlstop; + } + + /// Check all guild member lists against the entity translator + virtual void checkGuildMemberLists() + { + } + + // A character connect/disconnect on another shard, update the online tags + virtual void characterConnectionEvent(const NLMISC::CEntityId &eid, bool online) + { + } + + +}; + +CGuildManagerPH guildManager; + +IGuildManager &IGuildManager::getInstance() +{ + return guildManager; +} + + +IGuild *IGuild::getGuildInterface(::CGuild *guild) +{ + nlstop; + return NULL; +} + +void IGuild::setNameWrap(const ucstring &name) +{ + nlstop; +} +uint32 IGuild::getIdWrap() +{ + nlstop; + return 0; +} + +bool IGuild::isProxyWrap() +{ + nlstop; + return false; +} + +void IGuild::updateMembersStringIds() +{ + nlstop; +} + + +class CGuildPH : public IGuild +{ +}; + +//namespace RY_PDS +//{ +// bool CPDStringManager::isWaitingIOSStoreStringResult() +// { +// return false; +// } +//}; + + +Test::Suite *createCNopeTS(const std::string &workingPath); +Test::Suite *createCRSMTS(const std::string &workingPath); +Test::Suite *createCCharacterSyncTS(const std::string &workingPath); + + +class CShardUnifierTS: public Test::Suite +{ + string _WorkingPath; +// string _BaseDir; +// string _CurrentPath; +// string _CurrentPathToRestore; + + + NLMISC::CApplicationContext *_Context; + +public: + + CShardUnifierTS(const std::string &workingPath) + { + _Context = new CApplicationContext(); + // init a new nel instance + INelContext::getInstance(); + + _WorkingPath = workingPath; + + NLMISC::createDebug(); + +// add(auto_ptr(createCNopeTS(workingPath))); + add(auto_ptr(createCRSMTS(workingPath))); + add(auto_ptr(createCCharacterSyncTS(workingPath))); + + + } + + ~CShardUnifierTS() + { + CPath::setCurrentPath(_WorkingPath.c_str()); + +// delete _Context; + } + +}; + +auto_ptr intRegisterTestSuite(const std::string &workingPath) +{ + return static_cast(new CShardUnifierTS(workingPath)); +} + +NL_LIB_EXPORT_SYMBOL(registerTestSuite, void, intRegisterTestSuite); + diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.cpp b/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.cpp new file mode 100644 index 000000000..5dd5c24f7 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.cpp @@ -0,0 +1,2217 @@ + +///////////////////////////////////////////////////////////////// +// WARNING : this is a generated file, don't change it ! +///////////////////////////////////////////////////////////////// + +#include "test_mapping.h" + +namespace TM +{ + + void CRootTablePtr::linkPtr() + { + nlassert(_NextPtr == NULL); + nlassert(_PrevPtr == NULL); + if (_Ptr != NULL) + { + _NextPtr = _Ptr->getFirstPtr(); + if (_NextPtr != NULL) + { + _PrevPtr = _NextPtr->_PrevPtr; + _PrevPtr->_NextPtr = this; + _NextPtr->_PrevPtr = this; + } + else + { + _NextPtr = this; + _PrevPtr = this; + _Ptr->setFirstPtr(this); + } + } + } + + void CRootTablePtr::unlinkPtr() + { + if (_NextPtr == NULL) + { + nlassert(_PrevPtr == NULL); + return; + } + + if (_Ptr != NULL) + { + if (_NextPtr == this) + { + nlassert(_PrevPtr == this); + // last pointer ! + _Ptr->setFirstPtr(NULL); + } + else + { + if (_Ptr->getFirstPtr() == this) + { + // the first ptr is the current one, we need to switch to next one + _Ptr->setFirstPtr(_NextPtr); + } + } + + } + if (_NextPtr != this) + { + nlassert(_PrevPtr != this); + + _NextPtr->_PrevPtr = _PrevPtr; + _PrevPtr->_NextPtr = _NextPtr; + } + _NextPtr = NULL; + _PrevPtr = NULL; + } + + + CRootTable::TObjectCache CRootTable::_ObjectCache; + CRootTable::TReleasedObject CRootTable::_ReleasedObject; + + + // Destructor, delete any children + CRootTable::~CRootTable() + { + // release childs reference + if (_MapChilds != NULL) + delete _MapChilds; + if (_VectorChilds != NULL) + delete _VectorChilds; + + + if (_PtrList != NULL) + { + nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); + CRootTablePtr *ptr = _PtrList; + do + { + nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); + ptr = _PtrList->getNextPtr(); + } while(ptr != _PtrList); + nlstop; + } + // remove object from cache map + if (_Id != NOPE::INVALID_OBJECT_ID + && _ObjectState != NOPE::os_removed + && _ObjectState != NOPE::os_transient) + { + nldebug("NOPE: clearing CRootTable @%p from cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + else if (_ObjectState != NOPE::os_transient) + { + nlassert(_ObjectCache.find(_Id) == _ObjectCache.end()); + } + if (_ObjectState == NOPE::os_released) + { + removeFromReleased(); + } + else + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + if (it != _ReleasedObject.end()) + { + nlassert(it->second.find(this) == it->second.end()); + } + } + } + + void CRootTable::removeFromReleased() + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + nlassert(it != _ReleasedObject.end()); + TObjectSet &os = it->second; + + nlverify(os.erase(this) == 1); + + // nb : _ReleasedObject time entry are removed by the cache update + } + + bool CRootTable::create(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_transient); + + std::string qs; + qs = "INSERT INTO root_table ("; + + qs += ""; + qs += ") VALUES ("; + + qs += ")"; + + if (connection.query(qs)) + { + uint32 _id_ = connection.getLastGeneratedId(); + setObjectId(_id_); + + + setPersistentState(NOPE::os_clean); + + // update the parent class instance in cache if any + + return true; + } + + return false; + } + + bool CRootTable::update(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + if (getPersistentState() == NOPE::os_clean) + // the object is clean, just ignore the save + return true; + + std::string qs; + qs = "UPDATE root_table SET "; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + setPersistentState(NOPE::os_clean); + return true; + } + } + + return false; + } + + bool CRootTable::remove(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + std::string qs; + qs = "DELETE FROM root_table "; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + + { + // cascading deletion for map child MapChilds + nlassert(loadMapChilds(connection, __FILE__, __LINE__)); + + const std::map < uint32, CMapChildPtr > & childs = getMapChilds(); + + while (!childs.empty()) + { + getMapChildsById(childs.begin()->first)->remove(connection); + } + } + + { + // cascading deletion for single child OneChild + nlassert(loadOneChild(connection, __FILE__, __LINE__)); + + if (getOneChild() != NULL) + getOneChild()->remove(connection); + } + + { + // unreference (and update) for vector child VectorChilds + nlassert(loadVectorChilds(connection, __FILE__, __LINE__)); + + const std::vector < CVectorChildPtr > & childs = getVectorChilds(); + + for (uint i=0; i < childs.size(); ++i) + { + + getVectorChildsByIndex(i)->setParentId(0); + getVectorChildsByIndex(i)->update(connection); + } + } + + + // change the persistant state to 'removed'. + setPersistentState(NOPE::os_removed); + + // need to remove ref from parent class container (if any) + + // need to remove ref from parent (if any) + + + return true; + } + } + return false; + } + + bool CRootTable::removeById(MSW::CConnection &connection, uint32 id) + { + CRootTable *object = loadFromCache(id, true); + if (object != NULL) + { + return object->remove(connection); + } + // not in cache, run a SQL query + std::string qs; + qs = "DELETE FROM root_table "; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + // ok, the row is removed + return true; + } + } + + return false; + } + + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + CRootTable *CRootTable::loadFromCache(uint32 objectId, bool unrelease) + { + // look in the cache + TObjectCache::iterator it(_ObjectCache.find(objectId)); + if (it == _ObjectCache.end()) + { + // not found, return null + return NULL; + } + else + { + CRootTable *object = it->second; + + if (object->_ObjectState == NOPE::os_released) + { + if (unrelease) + { + // we need to remove this object from the released object set. + object->removeFromReleased(); + object->_ObjectState = NOPE::os_clean; + } + } + + return it->second; + } + } + // Receive and execute command from the cache manager. + uint32 CRootTable::cacheCmd(NOPE::TCacheCmd cmd) + { + if (cmd == NOPE::cc_update) + { + updateCache(); + } + else if (cmd == NOPE::cc_clear) + { + clearCache(); + } + else if (cmd == NOPE::cc_dump) + { + dump(); + } + else if (cmd == NOPE::cc_instance_count) + { + return _ObjectCache.size(); + } + + // default return value + return 0; + } + + void CRootTable::dump() + { + nlinfo(" Cache info for class CRootTable :"); + nlinfo(" There are %u object instances in cache", _ObjectCache.size()); + + // count the number of object in the released object set + uint32 nbReleased = 0; + + TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); + for (; first != last; ++first) + { + nbReleased += first->second.size(); + } + + nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); + } + + void CRootTable::updateCache() + { + if (_ReleasedObject.empty()) + return; + + // 30 s hold in cache + const time_t MAX_CACHE_OLD_TIME = 30; + + time_t now = NLMISC::CTime::getSecondsSince1970(); + + // look for object set older than MAX_CACHE_OLD_TIME and delete them + while (!_ReleasedObject.empty() && _ReleasedObject.begin()->first < now-MAX_CACHE_OLD_TIME) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + CRootTable *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void CRootTable::clearCache() + { + // remove any unreferenced object from the cache + while (!_ReleasedObject.empty()) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + CRootTable *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void CRootTable::registerUpdatable() + { + static bool registered = false; + if (!registered) + { + NOPE::CPersistentCache::getInstance().registerCache(&CRootTable::cacheCmd); + + registered = true; + } + } + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void CRootTable::setFirstPtr(CRootTablePtr *ptr) + { + _PtrList = ptr; + + if (ptr == NULL) + { + // this is the last pointer ! + if (_ObjectState == NOPE::os_transient + || _ObjectState == NOPE::os_removed) + { + // not a persistent object, or removed object, just delet it + delete this; + } + else if (_ObjectState != NOPE::os_removed) + { + setPersistentState(NOPE::os_released); + } + } + } + + // Set the persistent state of the object and do some house keeping + void CRootTable::setPersistentState(NOPE::TObjectState state) + { + nlassert(NOPE::AllowedTransition[_ObjectState][state] == true); + + if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) + { + // a release object gets removed (e.g. by remove by id) + + // delete the object + delete this; + + // no more to do + return; + } + + if (_ObjectState == NOPE::os_transient && state != NOPE::os_transient) + { + nldebug("NOPE: inserting CRootTable @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.insert(std::make_pair(_Id, this)).second); + } + + if (_ObjectState != NOPE::os_transient) + nlassert(_ObjectCache.find(_Id) != _ObjectCache.end()); + + _ObjectState = state; + + if (state == NOPE::os_released) + { + _ReleaseDate = NLMISC::CTime::getSecondsSince1970(); + nlverify(_ReleasedObject[_ReleaseDate].insert(this).second); + } + else if (state == NOPE::os_removed) + { + nldebug("NOPE: erasing CRootTable @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + } + + + CRootTablePtr CRootTable::load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum) + { + CRootTable *inCache = loadFromCache(id, true); + if (inCache != NULL) + { + return CRootTablePtr(inCache, filename, lineNum); + } + + std::string qs; + qs = "SELECT "; + + qs += "Id"; + + qs += " FROM root_table"; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + CRootTablePtr ret; + if (!connection.query(qs)) + { + return ret; + } + + MSW::CStoreResult *result = connection.storeResult().release(); + + nlassert(result->getNumRows() <= 1); + if (result->getNumRows() == 1) + { + ret.assign(new CRootTable, filename, lineNum); + // ok, we have an object + result->fetchRow(); + + result->getField(0, ret->_Id); + + + ret->setPersistentState(NOPE::os_clean); + } + + delete result; + + return ret; + } + + + bool CRootTable::loadMapChilds(MSW::CConnection &connection, const char *filename, uint32 lineNum) + { + bool ret = true; + if (_MapChilds != NULL) + { + // the children are already loaded, just return true + return true; + } + + // allocate the container + _MapChilds = new std::map < uint32, CMapChildPtr >; + + // load the childs + ret &= CMapChild::loadChildrenOfCRootTable(connection, getObjectId(), *_MapChilds, filename, lineNum); + return ret; + } + + + const std::map &CRootTable::getMapChilds() const + { + nlassert(_MapChilds != NULL); + return *_MapChilds; + } + + CMapChildPtr &CRootTable::getMapChildsById(uint32 id) const + { + nlassert(_MapChilds != NULL); + std::map::const_iterator it(_MapChilds->find(id)); + + if (it == _MapChilds->end()) + { + // no object with this id, return a null pointer + static CMapChildPtr nil; + return nil; + } + + return const_cast< CMapChildPtr & >(it->second); + } + + + bool CRootTable::loadVectorChilds(MSW::CConnection &connection, const char *filename, uint32 lineNum) + { + bool ret = true; + if (_VectorChilds != NULL) + { + // the children are already loaded, just return true + return true; + } + + // allocate the container + _VectorChilds = new std::vector < CVectorChildPtr >; + + // load the childs + ret &= CVectorChild::loadChildrenOfCRootTable(connection, getObjectId(), *_VectorChilds, filename, lineNum); + return ret; + } + + + const std::vector &CRootTable::getVectorChilds() const + { + nlassert(_VectorChilds != NULL); + return *_VectorChilds; + } + + CVectorChildPtr &CRootTable::getVectorChildsByIndex(uint32 index) const + { + nlassert(_VectorChilds != NULL); + nlassert(index < _VectorChilds->size()); + return const_cast< CVectorChildPtr & >(_VectorChilds->operator[](index)); + } + + CVectorChildPtr &CRootTable::getVectorChildsById(uint32 id) const + { + nlassert(_VectorChilds != NULL); + std::vector::const_iterator first(_VectorChilds->begin()), last(_VectorChilds->end()); + for (; first != last; ++first) + { + const CVectorChildPtr &child = *first; + if (child->getObjectId() == id) + { + return const_cast< CVectorChildPtr & >(child); + } + } + + // no object with this id, return a null pointer + static CVectorChildPtr nil; + + return nil; + } + + + bool CRootTable::loadOneChild(MSW::CConnection &connection, const char *filename, uint32 lineNum) + { + if (_OneChildLoaded) + { + // the child is already loaded, just return true + return true; + } + bool ret = COneChild::loadChildOfCRootTable(connection, getObjectId(), _OneChild, filename, lineNum); + _OneChildLoaded = true; + return ret; + } + + /** Return the one child object (or null if not) */ + COneChildPtr CRootTable::getOneChild() + { + nlassert(_OneChildLoaded); + return _OneChild; + } + + + void COneChildPtr::linkPtr() + { + nlassert(_NextPtr == NULL); + nlassert(_PrevPtr == NULL); + if (_Ptr != NULL) + { + _NextPtr = _Ptr->getFirstPtr(); + if (_NextPtr != NULL) + { + _PrevPtr = _NextPtr->_PrevPtr; + _PrevPtr->_NextPtr = this; + _NextPtr->_PrevPtr = this; + } + else + { + _NextPtr = this; + _PrevPtr = this; + _Ptr->setFirstPtr(this); + } + } + } + + void COneChildPtr::unlinkPtr() + { + if (_NextPtr == NULL) + { + nlassert(_PrevPtr == NULL); + return; + } + + if (_Ptr != NULL) + { + if (_NextPtr == this) + { + nlassert(_PrevPtr == this); + // last pointer ! + _Ptr->setFirstPtr(NULL); + } + else + { + if (_Ptr->getFirstPtr() == this) + { + // the first ptr is the current one, we need to switch to next one + _Ptr->setFirstPtr(_NextPtr); + } + } + + } + if (_NextPtr != this) + { + nlassert(_PrevPtr != this); + + _NextPtr->_PrevPtr = _PrevPtr; + _PrevPtr->_NextPtr = _NextPtr; + } + _NextPtr = NULL; + _PrevPtr = NULL; + } + + + COneChild::TObjectCache COneChild::_ObjectCache; + COneChild::TReleasedObject COneChild::_ReleasedObject; + + + // Destructor, delete any children + COneChild::~COneChild() + { + // release childs reference + + + if (_PtrList != NULL) + { + nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); + COneChildPtr *ptr = _PtrList; + do + { + nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); + ptr = _PtrList->getNextPtr(); + } while(ptr != _PtrList); + nlstop; + } + // remove object from cache map + if (_Id != NOPE::INVALID_OBJECT_ID + && _ObjectState != NOPE::os_removed + && _ObjectState != NOPE::os_transient) + { + nldebug("NOPE: clearing COneChild @%p from cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + else if (_ObjectState != NOPE::os_transient) + { + nlassert(_ObjectCache.find(_Id) == _ObjectCache.end()); + } + if (_ObjectState == NOPE::os_released) + { + removeFromReleased(); + } + else + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + if (it != _ReleasedObject.end()) + { + nlassert(it->second.find(this) == it->second.end()); + } + } + } + + void COneChild::removeFromReleased() + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + nlassert(it != _ReleasedObject.end()); + TObjectSet &os = it->second; + + nlverify(os.erase(this) == 1); + + // nb : _ReleasedObject time entry are removed by the cache update + } + + bool COneChild::create(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_transient); + + nlassert(_Id != 0); + std::string qs; + qs = "INSERT INTO one_child ("; + + qs += "Id"; + qs += ") VALUES ("; + + qs += "'"+MSW::escapeString(NLMISC::toString(_Id), connection)+"'"; + + qs += ")"; + + if (connection.query(qs)) + { + + + setPersistentState(NOPE::os_clean); + + // update the parent class instance in cache if any + + if (_Id != 0) + { + // need to update the parent class child if it is in the cache + CRootTable *parent = CRootTable::loadFromCache(_Id, false); + if (parent && parent->_OneChildLoaded) + { + nlassert(parent->_OneChild == NULL); + parent->_OneChild = COneChildPtr(this, __FILE__, __LINE__); + } + } + + return true; + } + + return false; + } + + bool COneChild::update(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + if (getPersistentState() == NOPE::os_clean) + // the object is clean, just ignore the save + return true; + + std::string qs; + qs = "UPDATE one_child SET "; + + qs += "Id = '"+MSW::escapeString(NLMISC::toString(_Id), connection)+"'"; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + setPersistentState(NOPE::os_clean); + return true; + } + } + + return false; + } + + bool COneChild::remove(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + std::string qs; + qs = "DELETE FROM one_child "; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + + + // change the persistant state to 'removed'. + setPersistentState(NOPE::os_removed); + + // need to remove ref from parent class container (if any) + + // need to remove ref from parent (if any) + + { + CRootTablePtr parent(CRootTable::loadFromCache(_Id, true), __FILE__, __LINE__); + if (parent != NULL && parent->_OneChildLoaded) + { + // assign a new NULL pointer + parent->_OneChild.assign(COneChildPtr(), __FILE__, __LINE__); + } + } + + + return true; + } + } + return false; + } + + bool COneChild::removeById(MSW::CConnection &connection, uint32 id) + { + COneChild *object = loadFromCache(id, true); + if (object != NULL) + { + return object->remove(connection); + } + // not in cache, run a SQL query + std::string qs; + qs = "DELETE FROM one_child "; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + // ok, the row is removed + return true; + } + } + + return false; + } + + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + COneChild *COneChild::loadFromCache(uint32 objectId, bool unrelease) + { + // look in the cache + TObjectCache::iterator it(_ObjectCache.find(objectId)); + if (it == _ObjectCache.end()) + { + // not found, return null + return NULL; + } + else + { + COneChild *object = it->second; + + if (object->_ObjectState == NOPE::os_released) + { + if (unrelease) + { + // we need to remove this object from the released object set. + object->removeFromReleased(); + object->_ObjectState = NOPE::os_clean; + } + } + + return it->second; + } + } + // Receive and execute command from the cache manager. + uint32 COneChild::cacheCmd(NOPE::TCacheCmd cmd) + { + if (cmd == NOPE::cc_update) + { + updateCache(); + } + else if (cmd == NOPE::cc_clear) + { + clearCache(); + } + else if (cmd == NOPE::cc_dump) + { + dump(); + } + else if (cmd == NOPE::cc_instance_count) + { + return _ObjectCache.size(); + } + + // default return value + return 0; + } + + void COneChild::dump() + { + nlinfo(" Cache info for class COneChild :"); + nlinfo(" There are %u object instances in cache", _ObjectCache.size()); + + // count the number of object in the released object set + uint32 nbReleased = 0; + + TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); + for (; first != last; ++first) + { + nbReleased += first->second.size(); + } + + nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); + } + + void COneChild::updateCache() + { + if (_ReleasedObject.empty()) + return; + + // 30 s hold in cache + const time_t MAX_CACHE_OLD_TIME = 30; + + time_t now = NLMISC::CTime::getSecondsSince1970(); + + // look for object set older than MAX_CACHE_OLD_TIME and delete them + while (!_ReleasedObject.empty() && _ReleasedObject.begin()->first < now-MAX_CACHE_OLD_TIME) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + COneChild *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void COneChild::clearCache() + { + // remove any unreferenced object from the cache + while (!_ReleasedObject.empty()) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + COneChild *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void COneChild::registerUpdatable() + { + static bool registered = false; + if (!registered) + { + NOPE::CPersistentCache::getInstance().registerCache(&COneChild::cacheCmd); + + registered = true; + } + } + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void COneChild::setFirstPtr(COneChildPtr *ptr) + { + _PtrList = ptr; + + if (ptr == NULL) + { + // this is the last pointer ! + if (_ObjectState == NOPE::os_transient + || _ObjectState == NOPE::os_removed) + { + // not a persistent object, or removed object, just delet it + delete this; + } + else if (_ObjectState != NOPE::os_removed) + { + setPersistentState(NOPE::os_released); + } + } + } + + // Set the persistent state of the object and do some house keeping + void COneChild::setPersistentState(NOPE::TObjectState state) + { + nlassert(NOPE::AllowedTransition[_ObjectState][state] == true); + + if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) + { + // a release object gets removed (e.g. by remove by id) + + // delete the object + delete this; + + // no more to do + return; + } + + if (_ObjectState == NOPE::os_transient && state != NOPE::os_transient) + { + nldebug("NOPE: inserting COneChild @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.insert(std::make_pair(_Id, this)).second); + } + + if (_ObjectState != NOPE::os_transient) + nlassert(_ObjectCache.find(_Id) != _ObjectCache.end()); + + _ObjectState = state; + + if (state == NOPE::os_released) + { + _ReleaseDate = NLMISC::CTime::getSecondsSince1970(); + nlverify(_ReleasedObject[_ReleaseDate].insert(this).second); + } + else if (state == NOPE::os_removed) + { + nldebug("NOPE: erasing COneChild @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + } + + + COneChildPtr COneChild::load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum) + { + COneChild *inCache = loadFromCache(id, true); + if (inCache != NULL) + { + return COneChildPtr(inCache, filename, lineNum); + } + + std::string qs; + qs = "SELECT "; + + qs += "Id"; + + qs += " FROM one_child"; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + COneChildPtr ret; + if (!connection.query(qs)) + { + return ret; + } + + MSW::CStoreResult *result = connection.storeResult().release(); + + nlassert(result->getNumRows() <= 1); + if (result->getNumRows() == 1) + { + ret.assign(new COneChild, filename, lineNum); + // ok, we have an object + result->fetchRow(); + + result->getField(0, ret->_Id); + + + ret->setPersistentState(NOPE::os_clean); + } + + delete result; + + return ret; + } + + bool COneChild::loadChildOfCRootTable(MSW::CConnection &connection, uint32 parentId, COneChildPtr &childPtr, const char *filename, uint32 lineNum) + { + std::string qs; + qs = "SELECT "; + + qs += "Id"; + + qs += " FROM one_child"; + qs += " WHERE Id = '"+NLMISC::toString(parentId)+"'"; + + COneChildPtr ret; + if (!connection.query(qs)) + { + childPtr = COneChildPtr(); + return false; + } + + std::auto_ptr result = connection.storeResult(); + + // check that the data description is consistent with database content + nlassert(result->getNumRows() <= 1); + + if (result->getNumRows() == 1) + { + COneChild *object = new COneChild; + // ok, we have an object + result->fetchRow(); + + result->getField(0, object->_Id); + COneChild *inCache = loadFromCache(object->_Id, true); + if (inCache != NULL) + { + ret.assign(inCache, filename, lineNum); + // no more needed + delete object; + } + else + { + object->setPersistentState(NOPE::os_clean); + ret.assign(object, filename, lineNum); + } + + childPtr = ret; + return true; + } + + // no result, but no error + childPtr = COneChildPtr(); + return true; + } + + void CMapChildPtr::linkPtr() + { + nlassert(_NextPtr == NULL); + nlassert(_PrevPtr == NULL); + if (_Ptr != NULL) + { + _NextPtr = _Ptr->getFirstPtr(); + if (_NextPtr != NULL) + { + _PrevPtr = _NextPtr->_PrevPtr; + _PrevPtr->_NextPtr = this; + _NextPtr->_PrevPtr = this; + } + else + { + _NextPtr = this; + _PrevPtr = this; + _Ptr->setFirstPtr(this); + } + } + } + + void CMapChildPtr::unlinkPtr() + { + if (_NextPtr == NULL) + { + nlassert(_PrevPtr == NULL); + return; + } + + if (_Ptr != NULL) + { + if (_NextPtr == this) + { + nlassert(_PrevPtr == this); + // last pointer ! + _Ptr->setFirstPtr(NULL); + } + else + { + if (_Ptr->getFirstPtr() == this) + { + // the first ptr is the current one, we need to switch to next one + _Ptr->setFirstPtr(_NextPtr); + } + } + + } + if (_NextPtr != this) + { + nlassert(_PrevPtr != this); + + _NextPtr->_PrevPtr = _PrevPtr; + _PrevPtr->_NextPtr = _NextPtr; + } + _NextPtr = NULL; + _PrevPtr = NULL; + } + + + CMapChild::TObjectCache CMapChild::_ObjectCache; + CMapChild::TReleasedObject CMapChild::_ReleasedObject; + + + // Destructor, delete any children + CMapChild::~CMapChild() + { + // release childs reference + + + if (_PtrList != NULL) + { + nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); + CMapChildPtr *ptr = _PtrList; + do + { + nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); + ptr = _PtrList->getNextPtr(); + } while(ptr != _PtrList); + nlstop; + } + // remove object from cache map + if (_Id != NOPE::INVALID_OBJECT_ID + && _ObjectState != NOPE::os_removed + && _ObjectState != NOPE::os_transient) + { + nldebug("NOPE: clearing CMapChild @%p from cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + else if (_ObjectState != NOPE::os_transient) + { + nlassert(_ObjectCache.find(_Id) == _ObjectCache.end()); + } + if (_ObjectState == NOPE::os_released) + { + removeFromReleased(); + } + else + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + if (it != _ReleasedObject.end()) + { + nlassert(it->second.find(this) == it->second.end()); + } + } + } + + void CMapChild::removeFromReleased() + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + nlassert(it != _ReleasedObject.end()); + TObjectSet &os = it->second; + + nlverify(os.erase(this) == 1); + + // nb : _ReleasedObject time entry are removed by the cache update + } + + bool CMapChild::create(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_transient); + + nlassert(_Id != 0); + std::string qs; + qs = "INSERT INTO map_child ("; + + qs += "Id, parent_id"; + qs += ") VALUES ("; + + qs += "'"+MSW::escapeString(NLMISC::toString(_Id), connection)+"'"; + qs += ", "; + qs += "'"+MSW::escapeString(NLMISC::toString(_ParentId), connection)+"'"; + + qs += ")"; + + if (connection.query(qs)) + { + + + setPersistentState(NOPE::os_clean); + + // update the parent class instance in cache if any + + if (_ParentId != 0) + { + // need to update the parent class child list if it is in the cache + CRootTable *parent = CRootTable::loadFromCache(_ParentId, false); + if (parent && parent->_MapChilds != NULL) + { + + nlverify(parent->_MapChilds->insert(std::make_pair(getObjectId(), CMapChildPtr(this, __FILE__, __LINE__))).second); + + } + } + + return true; + } + + return false; + } + + bool CMapChild::update(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + if (getPersistentState() == NOPE::os_clean) + // the object is clean, just ignore the save + return true; + + std::string qs; + qs = "UPDATE map_child SET "; + + qs += "Id = '"+MSW::escapeString(NLMISC::toString(_Id), connection)+"'"; + qs += ", "; + qs += "parent_id = '"+MSW::escapeString(NLMISC::toString(_ParentId), connection)+"'"; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + setPersistentState(NOPE::os_clean); + return true; + } + } + + return false; + } + + bool CMapChild::remove(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + std::string qs; + qs = "DELETE FROM map_child "; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + + + // change the persistant state to 'removed'. + setPersistentState(NOPE::os_removed); + + // need to remove ref from parent class container (if any) + + { + CRootTablePtr parent(CRootTable::loadFromCache(_ParentId, true), __FILE__, __LINE__); + if (parent != NULL && parent->_MapChilds != NULL) + { + + parent->_MapChilds->erase(getObjectId()); + + } + } + + // need to remove ref from parent (if any) + + + return true; + } + } + return false; + } + + bool CMapChild::removeById(MSW::CConnection &connection, uint32 id) + { + CMapChild *object = loadFromCache(id, true); + if (object != NULL) + { + return object->remove(connection); + } + // not in cache, run a SQL query + std::string qs; + qs = "DELETE FROM map_child "; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + // ok, the row is removed + return true; + } + } + + return false; + } + + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + CMapChild *CMapChild::loadFromCache(uint32 objectId, bool unrelease) + { + // look in the cache + TObjectCache::iterator it(_ObjectCache.find(objectId)); + if (it == _ObjectCache.end()) + { + // not found, return null + return NULL; + } + else + { + CMapChild *object = it->second; + + if (object->_ObjectState == NOPE::os_released) + { + if (unrelease) + { + // we need to remove this object from the released object set. + object->removeFromReleased(); + object->_ObjectState = NOPE::os_clean; + } + } + + return it->second; + } + } + // Receive and execute command from the cache manager. + uint32 CMapChild::cacheCmd(NOPE::TCacheCmd cmd) + { + if (cmd == NOPE::cc_update) + { + updateCache(); + } + else if (cmd == NOPE::cc_clear) + { + clearCache(); + } + else if (cmd == NOPE::cc_dump) + { + dump(); + } + else if (cmd == NOPE::cc_instance_count) + { + return _ObjectCache.size(); + } + + // default return value + return 0; + } + + void CMapChild::dump() + { + nlinfo(" Cache info for class CMapChild :"); + nlinfo(" There are %u object instances in cache", _ObjectCache.size()); + + // count the number of object in the released object set + uint32 nbReleased = 0; + + TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); + for (; first != last; ++first) + { + nbReleased += first->second.size(); + } + + nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); + } + + void CMapChild::updateCache() + { + if (_ReleasedObject.empty()) + return; + + // 30 s hold in cache + const time_t MAX_CACHE_OLD_TIME = 30; + + time_t now = NLMISC::CTime::getSecondsSince1970(); + + // look for object set older than MAX_CACHE_OLD_TIME and delete them + while (!_ReleasedObject.empty() && _ReleasedObject.begin()->first < now-MAX_CACHE_OLD_TIME) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + CMapChild *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void CMapChild::clearCache() + { + // remove any unreferenced object from the cache + while (!_ReleasedObject.empty()) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + CMapChild *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void CMapChild::registerUpdatable() + { + static bool registered = false; + if (!registered) + { + NOPE::CPersistentCache::getInstance().registerCache(&CMapChild::cacheCmd); + + registered = true; + } + } + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void CMapChild::setFirstPtr(CMapChildPtr *ptr) + { + _PtrList = ptr; + + if (ptr == NULL) + { + // this is the last pointer ! + if (_ObjectState == NOPE::os_transient + || _ObjectState == NOPE::os_removed) + { + // not a persistent object, or removed object, just delet it + delete this; + } + else if (_ObjectState != NOPE::os_removed) + { + setPersistentState(NOPE::os_released); + } + } + } + + // Set the persistent state of the object and do some house keeping + void CMapChild::setPersistentState(NOPE::TObjectState state) + { + nlassert(NOPE::AllowedTransition[_ObjectState][state] == true); + + if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) + { + // a release object gets removed (e.g. by remove by id) + + // delete the object + delete this; + + // no more to do + return; + } + + if (_ObjectState == NOPE::os_transient && state != NOPE::os_transient) + { + nldebug("NOPE: inserting CMapChild @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.insert(std::make_pair(_Id, this)).second); + } + + if (_ObjectState != NOPE::os_transient) + nlassert(_ObjectCache.find(_Id) != _ObjectCache.end()); + + _ObjectState = state; + + if (state == NOPE::os_released) + { + _ReleaseDate = NLMISC::CTime::getSecondsSince1970(); + nlverify(_ReleasedObject[_ReleaseDate].insert(this).second); + } + else if (state == NOPE::os_removed) + { + nldebug("NOPE: erasing CMapChild @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + } + + + CMapChildPtr CMapChild::load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum) + { + CMapChild *inCache = loadFromCache(id, true); + if (inCache != NULL) + { + return CMapChildPtr(inCache, filename, lineNum); + } + + std::string qs; + qs = "SELECT "; + + qs += "Id, parent_id"; + + qs += " FROM map_child"; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + CMapChildPtr ret; + if (!connection.query(qs)) + { + return ret; + } + + MSW::CStoreResult *result = connection.storeResult().release(); + + nlassert(result->getNumRows() <= 1); + if (result->getNumRows() == 1) + { + ret.assign(new CMapChild, filename, lineNum); + // ok, we have an object + result->fetchRow(); + + result->getField(0, ret->_Id); + result->getField(1, ret->_ParentId); + + + ret->setPersistentState(NOPE::os_clean); + } + + delete result; + + return ret; + } + + + bool CMapChild::loadChildrenOfCRootTable(MSW::CConnection &connection, uint32 parentId, std::map < uint32, CMapChildPtr > & container, const char *filename, uint32 lineNum) + + { + std::string qs; + qs = "SELECT "; + + qs += "Id, parent_id"; + + qs += " FROM map_child"; + qs += " WHERE parent_id = '"+NLMISC::toString(parentId)+"'"; + + if (!connection.query(qs)) + { + return false; + } + + std::auto_ptr result = connection.storeResult(); + + for (uint i=0; igetNumRows(); ++i) + { + CMapChild *ret = new CMapChild(); + // ok, we have an object + result->fetchRow(); + + result->getField(0, ret->_Id); + + result->getField(1, ret->_ParentId); + CMapChild *inCache = loadFromCache(ret->_Id, true); + if (inCache != NULL) + { + + container.insert(std::make_pair(inCache->getObjectId(), CMapChildPtr(inCache, filename, lineNum))); + + // no more needed + delete ret; + } + else + { + ret->setPersistentState(NOPE::os_clean); + + container.insert(std::make_pair(ret->getObjectId(), CMapChildPtr(ret, filename, lineNum))); + + } + } + + return true; + } + + void CVectorChildPtr::linkPtr() + { + nlassert(_NextPtr == NULL); + nlassert(_PrevPtr == NULL); + if (_Ptr != NULL) + { + _NextPtr = _Ptr->getFirstPtr(); + if (_NextPtr != NULL) + { + _PrevPtr = _NextPtr->_PrevPtr; + _PrevPtr->_NextPtr = this; + _NextPtr->_PrevPtr = this; + } + else + { + _NextPtr = this; + _PrevPtr = this; + _Ptr->setFirstPtr(this); + } + } + } + + void CVectorChildPtr::unlinkPtr() + { + if (_NextPtr == NULL) + { + nlassert(_PrevPtr == NULL); + return; + } + + if (_Ptr != NULL) + { + if (_NextPtr == this) + { + nlassert(_PrevPtr == this); + // last pointer ! + _Ptr->setFirstPtr(NULL); + } + else + { + if (_Ptr->getFirstPtr() == this) + { + // the first ptr is the current one, we need to switch to next one + _Ptr->setFirstPtr(_NextPtr); + } + } + + } + if (_NextPtr != this) + { + nlassert(_PrevPtr != this); + + _NextPtr->_PrevPtr = _PrevPtr; + _PrevPtr->_NextPtr = _NextPtr; + } + _NextPtr = NULL; + _PrevPtr = NULL; + } + + + CVectorChild::TObjectCache CVectorChild::_ObjectCache; + CVectorChild::TReleasedObject CVectorChild::_ReleasedObject; + + + // Destructor, delete any children + CVectorChild::~CVectorChild() + { + // release childs reference + + + if (_PtrList != NULL) + { + nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); + CVectorChildPtr *ptr = _PtrList; + do + { + nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); + ptr = _PtrList->getNextPtr(); + } while(ptr != _PtrList); + nlstop; + } + // remove object from cache map + if (_Id != NOPE::INVALID_OBJECT_ID + && _ObjectState != NOPE::os_removed + && _ObjectState != NOPE::os_transient) + { + nldebug("NOPE: clearing CVectorChild @%p from cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + else if (_ObjectState != NOPE::os_transient) + { + nlassert(_ObjectCache.find(_Id) == _ObjectCache.end()); + } + if (_ObjectState == NOPE::os_released) + { + removeFromReleased(); + } + else + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + if (it != _ReleasedObject.end()) + { + nlassert(it->second.find(this) == it->second.end()); + } + } + } + + void CVectorChild::removeFromReleased() + { + TReleasedObject::iterator it(_ReleasedObject.find(_ReleaseDate)); + nlassert(it != _ReleasedObject.end()); + TObjectSet &os = it->second; + + nlverify(os.erase(this) == 1); + + // nb : _ReleasedObject time entry are removed by the cache update + } + + bool CVectorChild::create(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_transient); + + nlassert(_Id != 0); + std::string qs; + qs = "INSERT INTO vector_child ("; + + qs += "Id, parent_id, info"; + qs += ") VALUES ("; + + qs += "'"+MSW::escapeString(NLMISC::toString(_Id), connection)+"'"; + qs += ", "; + qs += "'"+MSW::escapeString(NLMISC::toString(_ParentId), connection)+"'"; + qs += ", "; + qs += "'"+MSW::escapeString(NLMISC::toString(_Info), connection)+"'"; + + qs += ")"; + + if (connection.query(qs)) + { + + + setPersistentState(NOPE::os_clean); + + // update the parent class instance in cache if any + + if (_ParentId != 0) + { + // need to update the parent class child list if it is in the cache + CRootTable *parent = CRootTable::loadFromCache(_ParentId, false); + if (parent && parent->_VectorChilds != NULL) + { + + nlassert(std::find(parent->_VectorChilds->begin(), parent->_VectorChilds->end(), CVectorChildPtr(this, __FILE__, __LINE__)) == parent->_VectorChilds->end()); + parent->_VectorChilds->push_back(CVectorChildPtr(this, __FILE__, __LINE__)); + + } + } + + return true; + } + + return false; + } + + bool CVectorChild::update(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + if (getPersistentState() == NOPE::os_clean) + // the object is clean, just ignore the save + return true; + + std::string qs; + qs = "UPDATE vector_child SET "; + + qs += "Id = '"+MSW::escapeString(NLMISC::toString(_Id), connection)+"'"; + qs += ", "; + qs += "parent_id = '"+MSW::escapeString(NLMISC::toString(_ParentId), connection)+"'"; + qs += ", "; + qs += "info = '"+MSW::escapeString(NLMISC::toString(_Info), connection)+"'"; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + setPersistentState(NOPE::os_clean); + return true; + } + } + + return false; + } + + bool CVectorChild::remove(MSW::CConnection &connection) + { + nlassert(getPersistentState() == NOPE::os_dirty || getPersistentState() == NOPE::os_clean); + + std::string qs; + qs = "DELETE FROM vector_child "; + + qs += " WHERE Id = '"+NLMISC::toString(_Id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + + + // change the persistant state to 'removed'. + setPersistentState(NOPE::os_removed); + + // need to remove ref from parent class container (if any) + + { + CRootTablePtr parent(CRootTable::loadFromCache(_ParentId, true), __FILE__, __LINE__); + if (parent != NULL && parent->_VectorChilds != NULL) + { + + std::vector < CVectorChildPtr >::iterator it = std::find(parent->_VectorChilds->begin(), parent->_VectorChilds->end(), this); + if (it != parent->_VectorChilds->end()) + { + parent->_VectorChilds->erase(it); + } + + } + } + + // need to remove ref from parent (if any) + + + return true; + } + } + return false; + } + + bool CVectorChild::removeById(MSW::CConnection &connection, uint32 id) + { + CVectorChild *object = loadFromCache(id, true); + if (object != NULL) + { + return object->remove(connection); + } + // not in cache, run a SQL query + std::string qs; + qs = "DELETE FROM vector_child "; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + + + if (connection.query(qs)) + { + if (connection.getAffectedRows() == 1) + { + // ok, the row is removed + return true; + } + } + + return false; + } + + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + CVectorChild *CVectorChild::loadFromCache(uint32 objectId, bool unrelease) + { + // look in the cache + TObjectCache::iterator it(_ObjectCache.find(objectId)); + if (it == _ObjectCache.end()) + { + // not found, return null + return NULL; + } + else + { + CVectorChild *object = it->second; + + if (object->_ObjectState == NOPE::os_released) + { + if (unrelease) + { + // we need to remove this object from the released object set. + object->removeFromReleased(); + object->_ObjectState = NOPE::os_clean; + } + } + + return it->second; + } + } + // Receive and execute command from the cache manager. + uint32 CVectorChild::cacheCmd(NOPE::TCacheCmd cmd) + { + if (cmd == NOPE::cc_update) + { + updateCache(); + } + else if (cmd == NOPE::cc_clear) + { + clearCache(); + } + else if (cmd == NOPE::cc_dump) + { + dump(); + } + else if (cmd == NOPE::cc_instance_count) + { + return _ObjectCache.size(); + } + + // default return value + return 0; + } + + void CVectorChild::dump() + { + nlinfo(" Cache info for class CVectorChild :"); + nlinfo(" There are %u object instances in cache", _ObjectCache.size()); + + // count the number of object in the released object set + uint32 nbReleased = 0; + + TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); + for (; first != last; ++first) + { + nbReleased += first->second.size(); + } + + nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); + } + + void CVectorChild::updateCache() + { + if (_ReleasedObject.empty()) + return; + + // 30 s hold in cache + const time_t MAX_CACHE_OLD_TIME = 30; + + time_t now = NLMISC::CTime::getSecondsSince1970(); + + // look for object set older than MAX_CACHE_OLD_TIME and delete them + while (!_ReleasedObject.empty() && _ReleasedObject.begin()->first < now-MAX_CACHE_OLD_TIME) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + CVectorChild *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void CVectorChild::clearCache() + { + // remove any unreferenced object from the cache + while (!_ReleasedObject.empty()) + { + TObjectSet &delSet = _ReleasedObject.begin()->second; + // unload this objects + while (!delSet.empty()) + { + CVectorChild *object = *delSet.begin(); + delete object; + } + + _ReleasedObject.erase(_ReleasedObject.begin()); + } + } + + void CVectorChild::registerUpdatable() + { + static bool registered = false; + if (!registered) + { + NOPE::CPersistentCache::getInstance().registerCache(&CVectorChild::cacheCmd); + + registered = true; + } + } + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void CVectorChild::setFirstPtr(CVectorChildPtr *ptr) + { + _PtrList = ptr; + + if (ptr == NULL) + { + // this is the last pointer ! + if (_ObjectState == NOPE::os_transient + || _ObjectState == NOPE::os_removed) + { + // not a persistent object, or removed object, just delet it + delete this; + } + else if (_ObjectState != NOPE::os_removed) + { + setPersistentState(NOPE::os_released); + } + } + } + + // Set the persistent state of the object and do some house keeping + void CVectorChild::setPersistentState(NOPE::TObjectState state) + { + nlassert(NOPE::AllowedTransition[_ObjectState][state] == true); + + if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) + { + // a release object gets removed (e.g. by remove by id) + + // delete the object + delete this; + + // no more to do + return; + } + + if (_ObjectState == NOPE::os_transient && state != NOPE::os_transient) + { + nldebug("NOPE: inserting CVectorChild @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.insert(std::make_pair(_Id, this)).second); + } + + if (_ObjectState != NOPE::os_transient) + nlassert(_ObjectCache.find(_Id) != _ObjectCache.end()); + + _ObjectState = state; + + if (state == NOPE::os_released) + { + _ReleaseDate = NLMISC::CTime::getSecondsSince1970(); + nlverify(_ReleasedObject[_ReleaseDate].insert(this).second); + } + else if (state == NOPE::os_removed) + { + nldebug("NOPE: erasing CVectorChild @%p in cache with id %u", this, static_cast(_Id)); + nlverify(_ObjectCache.erase(_Id) == 1); + } + } + + + CVectorChildPtr CVectorChild::load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum) + { + CVectorChild *inCache = loadFromCache(id, true); + if (inCache != NULL) + { + return CVectorChildPtr(inCache, filename, lineNum); + } + + std::string qs; + qs = "SELECT "; + + qs += "Id, parent_id, info"; + + qs += " FROM vector_child"; + + qs += " WHERE Id = '"+NLMISC::toString(id)+"'"; + CVectorChildPtr ret; + if (!connection.query(qs)) + { + return ret; + } + + MSW::CStoreResult *result = connection.storeResult().release(); + + nlassert(result->getNumRows() <= 1); + if (result->getNumRows() == 1) + { + ret.assign(new CVectorChild, filename, lineNum); + // ok, we have an object + result->fetchRow(); + + result->getField(0, ret->_Id); + result->getField(1, ret->_ParentId); + result->getField(2, ret->_Info); + + + ret->setPersistentState(NOPE::os_clean); + } + + delete result; + + return ret; + } + + + bool CVectorChild::loadChildrenOfCRootTable(MSW::CConnection &connection, uint32 parentId, std::vector < CVectorChildPtr > & container, const char *filename, uint32 lineNum) + + { + std::string qs; + qs = "SELECT "; + + qs += "Id, parent_id, info"; + + qs += " FROM vector_child"; + qs += " WHERE parent_id = '"+NLMISC::toString(parentId)+"'"; + + if (!connection.query(qs)) + { + return false; + } + + std::auto_ptr result = connection.storeResult(); + + for (uint i=0; igetNumRows(); ++i) + { + CVectorChild *ret = new CVectorChild(); + // ok, we have an object + result->fetchRow(); + + result->getField(0, ret->_Id); + + result->getField(1, ret->_ParentId); + + result->getField(2, ret->_Info); + CVectorChild *inCache = loadFromCache(ret->_Id, true); + if (inCache != NULL) + { + + container.push_back(CVectorChildPtr(inCache, filename, lineNum)); + + // no more needed + delete ret; + } + else + { + ret->setPersistentState(NOPE::os_clean); + + container.push_back(CVectorChildPtr(ret, filename, lineNum)); + + } + } + + return true; + } + +} diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.h b/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.h new file mode 100644 index 000000000..439847c74 --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.h @@ -0,0 +1,1428 @@ + +///////////////////////////////////////////////////////////////// +// WARNING : this is a generated file, don't change it ! +///////////////////////////////////////////////////////////////// + +#ifndef TEST_MAPPING +#define TEST_MAPPING +#include "nel/misc/types_nl.h" +#ifdef NL_COMP_VC8 + #include +#endif +#include "nel/misc/hierarchical_timer.h" +#include "nel/misc/string_conversion.h" +#include "nel/net/message.h" +#include "nel/net/module.h" +#include "nel/net/module_builder_parts.h" +#include "nel/net/module_message.h" +#include "nel/net/module_gateway.h" + +#include "nel/misc/string_common.h" +#include "game_share/mysql_wrapper.h" + +namespace TM +{ + + class CRootTable; + + class CRootTablePtr; + class COneChild; + + class COneChildPtr; + class CMapChild; + + class CMapChildPtr; + class CVectorChild; + + class CVectorChildPtr; + + + + class CRootTablePtr + { + friend class CRootTable; + + const char *_FileName; + uint32 _LineNum; + + // linked list of smart ptr + CRootTablePtr *_NextPtr; + CRootTablePtr *_PrevPtr; + + CRootTable *_Ptr; + + void linkPtr(); + + void unlinkPtr(); + + public: + CRootTablePtr() + : _FileName(NULL), + _LineNum(0), + _Ptr(NULL), + _NextPtr(NULL), + _PrevPtr(NULL) + { + } + + CRootTablePtr(const CRootTablePtr &other, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + CRootTablePtr(const CRootTablePtr &other) + : _FileName(other._FileName), + _LineNum(other._LineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + CRootTablePtr(CRootTable *objectPtr, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + _Ptr = objectPtr; + + linkPtr(); + } + + CRootTablePtr &assign(const CRootTablePtr &other, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = other._Ptr; + linkPtr(); + + return *this; + } + + ~CRootTablePtr() + { + unlinkPtr(); + } + + CRootTablePtr &assign(CRootTable *objectPtr, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = objectPtr; + linkPtr(); + + return *this; + } + + CRootTablePtr &operator =(const CRootTablePtr &other) + { + return assign(other, __FILE__, __LINE__); + } + + CRootTable *operator ->() + { + return _Ptr; + } + const CRootTable *operator ->() const + { + return _Ptr; + } + + bool operator == (const CRootTablePtr &other) const + { + return _Ptr == other._Ptr; + } + bool operator != (const CRootTablePtr &other) const + { + return !operator ==(other); + } + + bool operator == (const CRootTable *object) const + { + return _Ptr == object; + } + bool operator != (const CRootTable *object) const + { + return !operator ==(object); + } + + /// Less then comparator : comparison on pointer object address + bool operator < (const CRootTablePtr &other) const + { + return _Ptr < other._Ptr; + } + + /// Used to walk thrue the linked list of pointer + CRootTablePtr *getNextPtr() + { + return _NextPtr; + } + }; + + + + + + class COneChildPtr + { + friend class COneChild; + + const char *_FileName; + uint32 _LineNum; + + // linked list of smart ptr + COneChildPtr *_NextPtr; + COneChildPtr *_PrevPtr; + + COneChild *_Ptr; + + void linkPtr(); + + void unlinkPtr(); + + public: + COneChildPtr() + : _FileName(NULL), + _LineNum(0), + _Ptr(NULL), + _NextPtr(NULL), + _PrevPtr(NULL) + { + } + + COneChildPtr(const COneChildPtr &other, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + COneChildPtr(const COneChildPtr &other) + : _FileName(other._FileName), + _LineNum(other._LineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + COneChildPtr(COneChild *objectPtr, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + _Ptr = objectPtr; + + linkPtr(); + } + + COneChildPtr &assign(const COneChildPtr &other, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = other._Ptr; + linkPtr(); + + return *this; + } + + ~COneChildPtr() + { + unlinkPtr(); + } + + COneChildPtr &assign(COneChild *objectPtr, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = objectPtr; + linkPtr(); + + return *this; + } + + COneChildPtr &operator =(const COneChildPtr &other) + { + return assign(other, __FILE__, __LINE__); + } + + COneChild *operator ->() + { + return _Ptr; + } + const COneChild *operator ->() const + { + return _Ptr; + } + + bool operator == (const COneChildPtr &other) const + { + return _Ptr == other._Ptr; + } + bool operator != (const COneChildPtr &other) const + { + return !operator ==(other); + } + + bool operator == (const COneChild *object) const + { + return _Ptr == object; + } + bool operator != (const COneChild *object) const + { + return !operator ==(object); + } + + /// Less then comparator : comparison on pointer object address + bool operator < (const COneChildPtr &other) const + { + return _Ptr < other._Ptr; + } + + /// Used to walk thrue the linked list of pointer + COneChildPtr *getNextPtr() + { + return _NextPtr; + } + }; + + + + + + class CMapChildPtr + { + friend class CMapChild; + + const char *_FileName; + uint32 _LineNum; + + // linked list of smart ptr + CMapChildPtr *_NextPtr; + CMapChildPtr *_PrevPtr; + + CMapChild *_Ptr; + + void linkPtr(); + + void unlinkPtr(); + + public: + CMapChildPtr() + : _FileName(NULL), + _LineNum(0), + _Ptr(NULL), + _NextPtr(NULL), + _PrevPtr(NULL) + { + } + + CMapChildPtr(const CMapChildPtr &other, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + CMapChildPtr(const CMapChildPtr &other) + : _FileName(other._FileName), + _LineNum(other._LineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + CMapChildPtr(CMapChild *objectPtr, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + _Ptr = objectPtr; + + linkPtr(); + } + + CMapChildPtr &assign(const CMapChildPtr &other, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = other._Ptr; + linkPtr(); + + return *this; + } + + ~CMapChildPtr() + { + unlinkPtr(); + } + + CMapChildPtr &assign(CMapChild *objectPtr, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = objectPtr; + linkPtr(); + + return *this; + } + + CMapChildPtr &operator =(const CMapChildPtr &other) + { + return assign(other, __FILE__, __LINE__); + } + + CMapChild *operator ->() + { + return _Ptr; + } + const CMapChild *operator ->() const + { + return _Ptr; + } + + bool operator == (const CMapChildPtr &other) const + { + return _Ptr == other._Ptr; + } + bool operator != (const CMapChildPtr &other) const + { + return !operator ==(other); + } + + bool operator == (const CMapChild *object) const + { + return _Ptr == object; + } + bool operator != (const CMapChild *object) const + { + return !operator ==(object); + } + + /// Less then comparator : comparison on pointer object address + bool operator < (const CMapChildPtr &other) const + { + return _Ptr < other._Ptr; + } + + /// Used to walk thrue the linked list of pointer + CMapChildPtr *getNextPtr() + { + return _NextPtr; + } + }; + + + + + + class CVectorChildPtr + { + friend class CVectorChild; + + const char *_FileName; + uint32 _LineNum; + + // linked list of smart ptr + CVectorChildPtr *_NextPtr; + CVectorChildPtr *_PrevPtr; + + CVectorChild *_Ptr; + + void linkPtr(); + + void unlinkPtr(); + + public: + CVectorChildPtr() + : _FileName(NULL), + _LineNum(0), + _Ptr(NULL), + _NextPtr(NULL), + _PrevPtr(NULL) + { + } + + CVectorChildPtr(const CVectorChildPtr &other, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + CVectorChildPtr(const CVectorChildPtr &other) + : _FileName(other._FileName), + _LineNum(other._LineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + // point the same object + _Ptr = other._Ptr; + // insert the pointer in the list + linkPtr(); + } + + CVectorChildPtr(CVectorChild *objectPtr, const char *filename, uint32 lineNum) + : _FileName(filename), + _LineNum(lineNum), + _NextPtr(NULL), + _PrevPtr(NULL) + { + _Ptr = objectPtr; + + linkPtr(); + } + + CVectorChildPtr &assign(const CVectorChildPtr &other, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = other._Ptr; + linkPtr(); + + return *this; + } + + ~CVectorChildPtr() + { + unlinkPtr(); + } + + CVectorChildPtr &assign(CVectorChild *objectPtr, const char *filename, uint32 lineNum) + { + _FileName = filename; + _LineNum = lineNum; + + unlinkPtr(); + _Ptr = objectPtr; + linkPtr(); + + return *this; + } + + CVectorChildPtr &operator =(const CVectorChildPtr &other) + { + return assign(other, __FILE__, __LINE__); + } + + CVectorChild *operator ->() + { + return _Ptr; + } + const CVectorChild *operator ->() const + { + return _Ptr; + } + + bool operator == (const CVectorChildPtr &other) const + { + return _Ptr == other._Ptr; + } + bool operator != (const CVectorChildPtr &other) const + { + return !operator ==(other); + } + + bool operator == (const CVectorChild *object) const + { + return _Ptr == object; + } + bool operator != (const CVectorChild *object) const + { + return !operator ==(object); + } + + /// Less then comparator : comparison on pointer object address + bool operator < (const CVectorChildPtr &other) const + { + return _Ptr < other._Ptr; + } + + /// Used to walk thrue the linked list of pointer + CVectorChildPtr *getNextPtr() + { + return _NextPtr; + } + }; + + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + class CRootTable + { + protected: + // + uint32 _Id; + + friend class CMapChild; + + std::map < uint32, CMapChildPtr > *_MapChilds; + + friend class CVectorChild; + + std::vector < CVectorChildPtr > *_VectorChilds; + friend class COneChild; + bool _OneChildLoaded; + COneChildPtr _OneChild; + public: + + /** Return the one child object (or null if not) */ + COneChildPtr getOneChild(); + + /** Return a const reference to the map of child. + * If you want to modify the element inside, you need to + * use on of the two following method who return non const pointer + * on contained elements. + */ + const std::map &getMapChilds() const; + /** Return the identified element by looking in the map + * If no element match the id, NULL pointer is returned + */ + CMapChildPtr &getMapChildsById(uint32 id) const; + + + /** Return a const reference to the vector of child. + * If you want to modify the element inside, you need to + * use on of the two following methods who return non const pointer + * on contained elements. + */ + const std::vector &getVectorChilds() const; + /** Return the ith element of the child vector + * index must be valid (ie less than size of the vector) + */ + CVectorChildPtr &getVectorChildsByIndex(uint32 index) const; + /** Return the identified element by looking in the vector + * If no element match the id, NULL pointer is returned + */ + CVectorChildPtr &getVectorChildsById(uint32 id) const; + + + bool operator == (const CRootTable &other) const + { + return _Id == other._Id; + } + + + private: + // private constructor, you must use 'createTransient' to get an instance + CRootTable() + : _PtrList(NULL), + _ObjectState(NOPE::os_transient), + _Id(NOPE::INVALID_OBJECT_ID) + { + _MapChilds = NULL; + _VectorChilds = NULL; + _OneChildLoaded = false; + + // register the cache for this class (if not already done) + registerUpdatable(); + } + + // Destructor, delete any children + ~CRootTable(); + + /// utility func to remove this object from the released object container + void removeFromReleased(); + + + public: + /// Create a new instance in the transient space + static CRootTablePtr createTransient(const char *filename, uint32 lineNum) + { + return CRootTablePtr(new CRootTable(), filename, lineNum); + } + + /** Create a new object in the database from the current object data. + * The object MUST be in transient state (i.e, it must be a new + * object created by user and not comming from the databse). + * If identifier is autogenerated, the generated id can be read after + * this call. + */ + bool create(MSW::CConnection &connection); + /** Update the database with the current object state. + * The object MUST be either in clean or dirty state. + * Return true if the object has been effectively stored + * in the database. + * After this call, the object is in 'clean' state. + */ + bool update(MSW::CConnection &connection); + /** Remove the current object from the persistent storage. + * The object must be in clean or dirty state. + * Return true if the object has been correctly + * updated in the database. + * After the call, the object is in 'clean' state. + */ + bool remove(MSW::CConnection &connection); + /** Remove an object from the persistent storage by specifying + * the id to remove. + * Return true if an entry as been effectively removed from + * the database. + * After the call, the object is in 'removed' state and should + * no more be used. A good pratice should be to delete + * the transient object just after the remove call. + */ + static bool removeById(MSW::CConnection &connection, uint32 id); + + /** Load an instance from the database. + * This call allocate a new object and load the property value + * from the database. + * Return NULL if the object id is not found. + */ + static CRootTablePtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum); + + + /// Load OneChild child(ren) object(s). + bool loadOneChild(MSW::CConnection &connection, const char *filename, uint32 lineNum); + + /// Load MapChilds child(ren) object(s). + bool loadMapChilds(MSW::CConnection &connection, const char *filename, uint32 lineNum); + + /// Load VectorChilds child(ren) object(s). + bool loadVectorChilds(MSW::CConnection &connection, const char *filename, uint32 lineNum); + + + private: + + private: + friend class CPersistentCache; + friend class CRootTablePtr; + + typedef std::map TObjectCache; + typedef std::set TObjectSet; + typedef std::map TReleasedObject; + + /// The complete set of object currently in memory (either active or released) excluding transient instance + static TObjectCache _ObjectCache; + /// The set of object in memory ut released (no pointer on them) and waiting for decommit + static TReleasedObject _ReleasedObject; + + /// The current object state + NOPE::TObjectState _ObjectState; + + /// For object in released state, this is the release date (used to trigger deletion of the object from memory) + time_t _ReleaseDate; + + /// The linked list of pointer on this object + CRootTablePtr *_PtrList; + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + static CRootTable *loadFromCache(uint32 objectId, bool unrelease); + + // Receive and execute command from the cache manager. + static uint32 cacheCmd(NOPE::TCacheCmd cmd); + + static void dump(); + + static void updateCache(); + + public: + static void clearCache(); + private: + void registerUpdatable(); + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void setFirstPtr(CRootTablePtr *ptr); + + // return the first pointer of the pointer list (can be null) + CRootTablePtr *getFirstPtr() + { + return _PtrList; + } + + public: + + /** Return the object identifier (witch is unique) + * You can only call this method on a persistent instance. + * (because transient instance can have invalid id) + */ + uint32 getObjectId() const + { + + nlassert(getPersistentState() != NOPE::os_transient); + return _Id; + } + + /** Set the object unique ID. + * You can only set the object id on a transient object + * having a non autogenerated unique id. + * Furthermore, you MUST set the id before calling create() + * if the id is not autogenerated. + */ + void setObjectId(uint32 objectId) + { + // can only be set when in transient state + nlassert(getPersistentState() == NOPE::os_transient); + // can only be set once + nlassert(_Id == NOPE::INVALID_OBJECT_ID); + _Id = objectId; + } + + /** Return the current persistent state of the object.*/ + NOPE::TObjectState getPersistentState() const + { + return _ObjectState; + } + + private: + // Set the persistent state of the object and do some house keeping + void setPersistentState(NOPE::TObjectState state); + + + + }; + + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + class COneChild + { + protected: + // + uint32 _Id; + public: + + bool operator == (const COneChild &other) const + { + return _Id == other._Id; + } + + + private: + // private constructor, you must use 'createTransient' to get an instance + COneChild() + : _PtrList(NULL), + _ObjectState(NOPE::os_transient), + _Id(NOPE::INVALID_OBJECT_ID) + { + + // register the cache for this class (if not already done) + registerUpdatable(); + } + + // Destructor, delete any children + ~COneChild(); + + /// utility func to remove this object from the released object container + void removeFromReleased(); + + + public: + /// Create a new instance in the transient space + static COneChildPtr createTransient(const char *filename, uint32 lineNum) + { + return COneChildPtr(new COneChild(), filename, lineNum); + } + + /** Create a new object in the database from the current object data. + * The object MUST be in transient state (i.e, it must be a new + * object created by user and not comming from the databse). + * If identifier is autogenerated, the generated id can be read after + * this call. + */ + bool create(MSW::CConnection &connection); + /** Update the database with the current object state. + * The object MUST be either in clean or dirty state. + * Return true if the object has been effectively stored + * in the database. + * After this call, the object is in 'clean' state. + */ + bool update(MSW::CConnection &connection); + /** Remove the current object from the persistent storage. + * The object must be in clean or dirty state. + * Return true if the object has been correctly + * updated in the database. + * After the call, the object is in 'clean' state. + */ + bool remove(MSW::CConnection &connection); + /** Remove an object from the persistent storage by specifying + * the id to remove. + * Return true if an entry as been effectively removed from + * the database. + * After the call, the object is in 'removed' state and should + * no more be used. A good pratice should be to delete + * the transient object just after the remove call. + */ + static bool removeById(MSW::CConnection &connection, uint32 id); + + /** Load an instance from the database. + * This call allocate a new object and load the property value + * from the database. + * Return NULL if the object id is not found. + */ + static COneChildPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum); + + + /** Load the object child of CRootTable and + * return true if no error, false in case of error (in SQL maybe). + * If no such object is found, fill the child pointer with NULL. + */ + static bool loadChildOfCRootTable(MSW::CConnection &connection, uint32 parentId, COneChildPtr &childPtr, const char *filename, uint32 lineNum); + + + private: + + private: + friend class CPersistentCache; + friend class COneChildPtr; + + typedef std::map TObjectCache; + typedef std::set TObjectSet; + typedef std::map TReleasedObject; + + /// The complete set of object currently in memory (either active or released) excluding transient instance + static TObjectCache _ObjectCache; + /// The set of object in memory ut released (no pointer on them) and waiting for decommit + static TReleasedObject _ReleasedObject; + + /// The current object state + NOPE::TObjectState _ObjectState; + + /// For object in released state, this is the release date (used to trigger deletion of the object from memory) + time_t _ReleaseDate; + + /// The linked list of pointer on this object + COneChildPtr *_PtrList; + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + static COneChild *loadFromCache(uint32 objectId, bool unrelease); + + // Receive and execute command from the cache manager. + static uint32 cacheCmd(NOPE::TCacheCmd cmd); + + static void dump(); + + static void updateCache(); + + public: + static void clearCache(); + private: + void registerUpdatable(); + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void setFirstPtr(COneChildPtr *ptr); + + // return the first pointer of the pointer list (can be null) + COneChildPtr *getFirstPtr() + { + return _PtrList; + } + + public: + + /** Return the object identifier (witch is unique) + * You can only call this method on a persistent instance. + * (because transient instance can have invalid id) + */ + uint32 getObjectId() const + { + + return _Id; + } + + /** Set the object unique ID. + * You can only set the object id on a transient object + * having a non autogenerated unique id. + * Furthermore, you MUST set the id before calling create() + * if the id is not autogenerated. + */ + void setObjectId(uint32 objectId) + { + // can only be set when in transient state + nlassert(getPersistentState() == NOPE::os_transient); + // can only be set once + nlassert(_Id == NOPE::INVALID_OBJECT_ID); + _Id = objectId; + } + + /** Return the current persistent state of the object.*/ + NOPE::TObjectState getPersistentState() const + { + return _ObjectState; + } + + private: + // Set the persistent state of the object and do some house keeping + void setPersistentState(NOPE::TObjectState state); + + + + }; + + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + class CMapChild + { + protected: + // + uint32 _Id; + // + uint32 _ParentId; + public: + // + uint32 getParentId() const + { + return _ParentId; + } + + void setParentId(uint32 value) + { + + if (_ParentId != value) + { + if (getPersistentState() != NOPE::os_transient) + setPersistentState(NOPE::os_dirty); + + _ParentId = value; + + } + + } + + bool operator == (const CMapChild &other) const + { + return _Id == other._Id + && _ParentId == other._ParentId; + } + + + private: + // private constructor, you must use 'createTransient' to get an instance + CMapChild() + : _PtrList(NULL), + _ObjectState(NOPE::os_transient), + _Id(NOPE::INVALID_OBJECT_ID) + { + + // register the cache for this class (if not already done) + registerUpdatable(); + } + + // Destructor, delete any children + ~CMapChild(); + + /// utility func to remove this object from the released object container + void removeFromReleased(); + + + public: + /// Create a new instance in the transient space + static CMapChildPtr createTransient(const char *filename, uint32 lineNum) + { + return CMapChildPtr(new CMapChild(), filename, lineNum); + } + + /** Create a new object in the database from the current object data. + * The object MUST be in transient state (i.e, it must be a new + * object created by user and not comming from the databse). + * If identifier is autogenerated, the generated id can be read after + * this call. + */ + bool create(MSW::CConnection &connection); + /** Update the database with the current object state. + * The object MUST be either in clean or dirty state. + * Return true if the object has been effectively stored + * in the database. + * After this call, the object is in 'clean' state. + */ + bool update(MSW::CConnection &connection); + /** Remove the current object from the persistent storage. + * The object must be in clean or dirty state. + * Return true if the object has been correctly + * updated in the database. + * After the call, the object is in 'clean' state. + */ + bool remove(MSW::CConnection &connection); + /** Remove an object from the persistent storage by specifying + * the id to remove. + * Return true if an entry as been effectively removed from + * the database. + * After the call, the object is in 'removed' state and should + * no more be used. A good pratice should be to delete + * the transient object just after the remove call. + */ + static bool removeById(MSW::CConnection &connection, uint32 id); + + /** Load an instance from the database. + * This call allocate a new object and load the property value + * from the database. + * Return NULL if the object id is not found. + */ + static CMapChildPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum); + + + /** Load all objects children of CRootTable and + * return them by using the specified output iterator. + */ + + static bool loadChildrenOfCRootTable(MSW::CConnection &connection, uint32 parentId, std::map < uint32, CMapChildPtr > &children, const char *filename, uint32 lineNum); + + + private: + + private: + friend class CPersistentCache; + friend class CMapChildPtr; + + typedef std::map TObjectCache; + typedef std::set TObjectSet; + typedef std::map TReleasedObject; + + /// The complete set of object currently in memory (either active or released) excluding transient instance + static TObjectCache _ObjectCache; + /// The set of object in memory ut released (no pointer on them) and waiting for decommit + static TReleasedObject _ReleasedObject; + + /// The current object state + NOPE::TObjectState _ObjectState; + + /// For object in released state, this is the release date (used to trigger deletion of the object from memory) + time_t _ReleaseDate; + + /// The linked list of pointer on this object + CMapChildPtr *_PtrList; + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + static CMapChild *loadFromCache(uint32 objectId, bool unrelease); + + // Receive and execute command from the cache manager. + static uint32 cacheCmd(NOPE::TCacheCmd cmd); + + static void dump(); + + static void updateCache(); + + public: + static void clearCache(); + private: + void registerUpdatable(); + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void setFirstPtr(CMapChildPtr *ptr); + + // return the first pointer of the pointer list (can be null) + CMapChildPtr *getFirstPtr() + { + return _PtrList; + } + + public: + + /** Return the object identifier (witch is unique) + * You can only call this method on a persistent instance. + * (because transient instance can have invalid id) + */ + uint32 getObjectId() const + { + + return _Id; + } + + /** Set the object unique ID. + * You can only set the object id on a transient object + * having a non autogenerated unique id. + * Furthermore, you MUST set the id before calling create() + * if the id is not autogenerated. + */ + void setObjectId(uint32 objectId) + { + // can only be set when in transient state + nlassert(getPersistentState() == NOPE::os_transient); + // can only be set once + nlassert(_Id == NOPE::INVALID_OBJECT_ID); + _Id = objectId; + } + + /** Return the current persistent state of the object.*/ + NOPE::TObjectState getPersistentState() const + { + return _ObjectState; + } + + private: + // Set the persistent state of the object and do some house keeping + void setPersistentState(NOPE::TObjectState state); + + + + }; + + + ///////////////////////////////////////////////////////////////// + // WARNING : this is a generated file, don't change it ! + ///////////////////////////////////////////////////////////////// + class CVectorChild + { + protected: + // + uint32 _Id; + // + uint32 _ParentId; + // + sint32 _Info; + public: + // + uint32 getParentId() const + { + return _ParentId; + } + + void setParentId(uint32 value) + { + + if (_ParentId != value) + { + if (getPersistentState() != NOPE::os_transient) + setPersistentState(NOPE::os_dirty); + + _ParentId = value; + + } + + } + // + sint32 getInfo() const + { + return _Info; + } + + void setInfo(sint32 value) + { + + if (_Info != value) + { + if (getPersistentState() != NOPE::os_transient) + setPersistentState(NOPE::os_dirty); + + _Info = value; + + } + + } + + bool operator == (const CVectorChild &other) const + { + return _Id == other._Id + && _ParentId == other._ParentId + && _Info == other._Info; + } + + + private: + // private constructor, you must use 'createTransient' to get an instance + CVectorChild() + : _PtrList(NULL), + _ObjectState(NOPE::os_transient), + _Id(NOPE::INVALID_OBJECT_ID) + { + + // register the cache for this class (if not already done) + registerUpdatable(); + } + + // Destructor, delete any children + ~CVectorChild(); + + /// utility func to remove this object from the released object container + void removeFromReleased(); + + + public: + /// Create a new instance in the transient space + static CVectorChildPtr createTransient(const char *filename, uint32 lineNum) + { + return CVectorChildPtr(new CVectorChild(), filename, lineNum); + } + + /** Create a new object in the database from the current object data. + * The object MUST be in transient state (i.e, it must be a new + * object created by user and not comming from the databse). + * If identifier is autogenerated, the generated id can be read after + * this call. + */ + bool create(MSW::CConnection &connection); + /** Update the database with the current object state. + * The object MUST be either in clean or dirty state. + * Return true if the object has been effectively stored + * in the database. + * After this call, the object is in 'clean' state. + */ + bool update(MSW::CConnection &connection); + /** Remove the current object from the persistent storage. + * The object must be in clean or dirty state. + * Return true if the object has been correctly + * updated in the database. + * After the call, the object is in 'clean' state. + */ + bool remove(MSW::CConnection &connection); + /** Remove an object from the persistent storage by specifying + * the id to remove. + * Return true if an entry as been effectively removed from + * the database. + * After the call, the object is in 'removed' state and should + * no more be used. A good pratice should be to delete + * the transient object just after the remove call. + */ + static bool removeById(MSW::CConnection &connection, uint32 id); + + /** Load an instance from the database. + * This call allocate a new object and load the property value + * from the database. + * Return NULL if the object id is not found. + */ + static CVectorChildPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum); + + + /** Load all objects children of CRootTable and + * return them by using the specified output iterator. + */ + + static bool loadChildrenOfCRootTable(MSW::CConnection &connection, uint32 parentId, std::vector < CVectorChildPtr > &children, const char *filename, uint32 lineNum); + + + private: + + private: + friend class CPersistentCache; + friend class CVectorChildPtr; + + typedef std::map TObjectCache; + typedef std::set TObjectSet; + typedef std::map TReleasedObject; + + /// The complete set of object currently in memory (either active or released) excluding transient instance + static TObjectCache _ObjectCache; + /// The set of object in memory ut released (no pointer on them) and waiting for decommit + static TReleasedObject _ReleasedObject; + + /// The current object state + NOPE::TObjectState _ObjectState; + + /// For object in released state, this is the release date (used to trigger deletion of the object from memory) + time_t _ReleaseDate; + + /// The linked list of pointer on this object + CVectorChildPtr *_PtrList; + + // Try to load the specified object from the memory cache, return NULL if the object is not in the cache + static CVectorChild *loadFromCache(uint32 objectId, bool unrelease); + + // Receive and execute command from the cache manager. + static uint32 cacheCmd(NOPE::TCacheCmd cmd); + + static void dump(); + + static void updateCache(); + + public: + static void clearCache(); + private: + void registerUpdatable(); + + // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer) + void setFirstPtr(CVectorChildPtr *ptr); + + // return the first pointer of the pointer list (can be null) + CVectorChildPtr *getFirstPtr() + { + return _PtrList; + } + + public: + + /** Return the object identifier (witch is unique) + * You can only call this method on a persistent instance. + * (because transient instance can have invalid id) + */ + uint32 getObjectId() const + { + + return _Id; + } + + /** Set the object unique ID. + * You can only set the object id on a transient object + * having a non autogenerated unique id. + * Furthermore, you MUST set the id before calling create() + * if the id is not autogenerated. + */ + void setObjectId(uint32 objectId) + { + // can only be set when in transient state + nlassert(getPersistentState() == NOPE::os_transient); + // can only be set once + nlassert(_Id == NOPE::INVALID_OBJECT_ID); + _Id = objectId; + } + + /** Return the current persistent state of the object.*/ + NOPE::TObjectState getPersistentState() const + { + return _ObjectState; + } + + private: + // Set the persistent state of the object and do some house keeping + void setPersistentState(NOPE::TObjectState state); + + + + }; + + + +} + +#endif diff --git a/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.xml b/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.xml new file mode 100644 index 000000000..d9963221d --- /dev/null +++ b/code/ryzom/tools/server/test_modules/shard_unifier_test/test_mapping.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/test_web_interface/test_web_interface.cpp b/code/ryzom/tools/server/test_web_interface/test_web_interface.cpp new file mode 100644 index 000000000..70823bd35 --- /dev/null +++ b/code/ryzom/tools/server/test_web_interface/test_web_interface.cpp @@ -0,0 +1,296 @@ + +#include "test_web_interface.h" +#include "test_web_interface_itf.h" +#include "nel/net/service.h" + +using namespace std; +using namespace NLMISC; +using namespace NLNET; +using namespace TWI; + +class CTestWebInterfaceServiceImpl + : public TWI::CTestInterfaceWebItf, + public TWI::CTestInterfaceWeb2Itf +{ + uint32 _TestState; +public: + + ///////////////////////////////////////// + /// Web interface callback imp + ///////////////////////////////////////// + virtual void on_CTestInterfaceWeb_Connection(NLNET::TSockId from) + { + nlinfo("Connect from %s, %s", from->asString().c_str(), from->getTcpSock()->remoteAddr().asString().c_str()); + } + + virtual void on_CTestInterfaceWeb_Disconnection(NLNET::TSockId from) + { + nlinfo("Disconnect from %s, %s", from->asString().c_str(), from->getTcpSock()->remoteAddr().asString().c_str()); + +// if (_TestState == 0 +// || _TestState == 1 +// || _TestState == 3 +// || _TestState == 5 +// || _TestState == 9 +// || _TestState == 13 +// || _TestState == 15 +// || _TestState == 17 +// || _TestState == 19) +// { +// // ok +// } +// else +// { +// nlwarning("Receive disconnect in state %u", _TestState); +//// nlstop; +// } +// +// if (_TestState > 0) +// _TestState++; + } + + virtual void on_beginTest(NLNET::TSockId from)\ + { + _TestState = 0; + } + + virtual void on_sendUInt32(NLNET::TSockId from, uint32 i32) + { + if (_TestState == 0) + { + nlassert(i32 == 0x12345678); + returnUInt32(from, 0x12345678); + } + else if (_TestState == 3) + { + nlassert(i32 == 0xFEDCBA98); + returnUInt32(from, 0x12345678); + } + else if (_TestState == 9) + { + nlassert(i32 == 0x12345678); + returnUInt32(from, 0x12345678); + returnUInt32(from, 0x87654321); + } + else if (_TestState == 10) + { + nlassert(i32 == 0x12345678); + returnUInt8(from, 0x34); + returnUInt32(from, 0x87654321); + } + else if (_TestState == 11) + { + nlassert(i32 == 0x12345678); + + // no response, live client alone and friendless + } + else + { + nlwarning("Received sendInt32 in state %u", _TestState); +// nlstop; + }; + + _TestState++; + } + + virtual void on_sendUInt8(NLNET::TSockId from, uint8 i8) + { + if (_TestState == 1) + { + nlassert(i8 == 0xf1); + returnUInt8(from, 0xf1); + } + else if (_TestState == 4) + { + nlassert(i8 == 0xcc); + returnUInt8(from, 0x01); + } + else + { + nlwarning("Received sendInt8 in state %u", _TestState); +// nlstop; + }; + + _TestState++; + } + + virtual void on_sendString(NLNET::TSockId from, const std::string &str) + { + if (_TestState == 2) + { + nlassert(str == "hello world"); + returnString(from, "hello world"); + } + else if (_TestState == 5) + { + nlassert(str == "hello world"); + returnString(from, "ok"); + } + else + { + nlwarning("Received sendString in state %u", _TestState); +// nlstop; + }; + + _TestState++; + } + + virtual void on_composite1(NLNET::TSockId from, uint32 i32, uint8 i8, const std::string &str) + { + if (_TestState == 6) + { + nlassert(i32 == 0x12345678); + nlassert(i8 == 0x9A); + nlassert(str == "Ibm"); + returnComposite1(from, 0x12345678, 0x9a, "hal"); + } + else + { + nlwarning("Received sendComposite1 in state %u", _TestState); +// nlstop; + }; + + _TestState++; + } + + virtual void on_composite2(NLNET::TSockId from, const std::string &str1, const std::string &str2, const std::string &str3, const std::string &str4) + { + if (_TestState == 7) + { + nlassert(str1 == "ABCD"); + nlassert(str2 == "EFGH IJKL"); + nlassert(str3 == "MNO"); + nlassert(str4 == "PQ"); + returnComposite2(from, "ABCD", "EFGH IJKL", "MNO", "PQ"); + } + else + { + nlwarning("Received sendComposite2 in state %u", _TestState); +// nlstop; + }; + + _TestState++; + } + + virtual void on_composite3(NLNET::TSockId from, uint8 i81, uint32 i321, const std::string &str1, uint8 i82, uint32 i322, const std::string &str2, uint8 i83, uint32 i323, const std::string &str3, uint8 i84, uint32 i324, const std::string &str4, uint32 i325, uint8 i85) + { + if (_TestState == 8) + { + nlassert(i81 == 0x9a); + nlassert(i321 == 0x12345678); + nlassert(str1 == "ABC"); + nlassert(i322 == 0xbcdef012); + nlassert(i82 == 0x34); + nlassert(str2 == "DEFGH"); + nlassert(i323 == 0x567890ab); + nlassert(i83 == 0xcd); + nlassert(str3 == "I"); + nlassert(i324 == 0xef012345); + nlassert(i84 == 0x67); + nlassert(str4 == ""); + nlassert(i325 == 0x01234567); + nlassert(i85 == 0x89); + + returnComposite3(from, 0x9a, 0x12345678, "ABC", + 0x34, 0xbcdef012, "DEFGH", + 0xcd, 0x567890ab, "I", + 0x67, 0xef012345, "", + 0x01234567, 0x89); + } + else + { + nlwarning("Received sendComposite3 in state %u", _TestState); +// nlstop; + }; + + _TestState++; + } + + /////////////////////////////////// + // Wel interface 2 impl + ////////////////////////////////// + /// Connection callback : a new interface client connect + virtual void on_CTestInterfaceWeb2_Connection(NLNET::TSockId from) + { + } + /// Disconnection callback : one of the interface client disconnect + virtual void on_CTestInterfaceWeb2_Disconnection(NLNET::TSockId from) + { + } + + + virtual void on_sendVectorUInt32(NLNET::TSockId from, const std::vector &vi32) + { + returnVectorUInt32(from, vi32); + } + + virtual void on_sendVectorString(NLNET::TSockId from, const std::vector &vstr) + { + returnVectorString(from, vstr); + } + + + virtual std::string on_twoWayCall(NLNET::TSockId from, const std::string ¶m) + { + return param; + } + + virtual uint32 on_twoWayCallInt(NLNET::TSockId from, uint32 param) + { + return param; + } + + virtual TEnum on_twoWayCallEnum(NLNET::TSockId from, TEnum param) + { + return param; + } + + virtual std::vector on_twoWayCallVector(NLNET::TSockId from, const std::vector ¶m) + { + return param; + } + + virtual void on_mixedVector(NLNET::TSockId from, uint32 param1, const std::vector &vstr, const std::vector &vi32) + { + returnMixedVector(from, param1, vstr, vi32); + } + + virtual uint32 on_mixedTwoWayVector(NLNET::TSockId from, uint32 param1, const std::vector &vstr, const std::vector &vi32) + { + return param1; + } + +}; + + +class CTestWebInterfaceService +: public IService +{ + + CTestWebInterfaceServiceImpl *_WebItf; +public: + void init () + { + _WebItf = new CTestWebInterfaceServiceImpl; + _WebItf->CTestInterfaceWebItf::openItf(8061); + _WebItf->CTestInterfaceWeb2Itf::openItf(8062); + } + bool update () + { + // update the web interface + _WebItf->CTestInterfaceWebItf::update(); + _WebItf->CTestInterfaceWeb2Itf::update(); + + return true; + } + void release () + { + delete _WebItf; + } +}; + +NLNET::TUnifiedCallbackItem cbArray[]= +{ "", NULL}; + +NLNET_SERVICE_MAIN(CTestWebInterfaceService, "WTI", "test_web_interface", 8060, cbArray, ".", "."); + diff --git a/code/ryzom/tools/server/test_web_interface/test_web_interface.h b/code/ryzom/tools/server/test_web_interface/test_web_interface.h new file mode 100644 index 000000000..f45f0daa4 --- /dev/null +++ b/code/ryzom/tools/server/test_web_interface/test_web_interface.h @@ -0,0 +1,4 @@ + + +#include "nel/net/service.h" + diff --git a/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.cpp b/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.cpp new file mode 100644 index 000000000..c94688227 --- /dev/null +++ b/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.cpp @@ -0,0 +1,11 @@ + +///////////////////////////////////////////////////////////////// +// WARNING : this is a generated file, don't change it ! +///////////////////////////////////////////////////////////////// + +#include "test_web_interface_itf.h" + +namespace TWI +{ + +} diff --git a/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.h b/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.h new file mode 100644 index 000000000..a4d325e33 --- /dev/null +++ b/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.h @@ -0,0 +1,1925 @@ + +///////////////////////////////////////////////////////////////// +// WARNING : this is a generated file, don't change it ! +///////////////////////////////////////////////////////////////// + +#ifndef TEST_WEB_INTERFACE_ITF +#define TEST_WEB_INTERFACE_ITF +#include "nel/misc/hierarchical_timer.h" +#include "nel/misc/string_conversion.h" +#include "nel/net/message.h" +#include "nel/net/module.h" +#include "nel/net/module_builder_parts.h" +#include "nel/net/module_message.h" +#include "nel/net/module_gateway.h" + +#include "game_share/callback_adaptor.h" + +namespace TWI +{ + + // Test interface for web to C++ messaging + + class CTestInterfaceWebItf + { + protected: + + /// the callback server adaptor + std::auto_ptr _CallbackServer; + + void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) + { + static NLNET::TCallbackItem callbackArray[] = + { + { "BT", CTestInterfaceWebItf::cb_beginTest }, + { "S32", CTestInterfaceWebItf::cb_sendUInt32 }, + { "S8", CTestInterfaceWebItf::cb_sendUInt8 }, + { "SS", CTestInterfaceWebItf::cb_sendString }, + { "SC1", CTestInterfaceWebItf::cb_composite1 }, + { "SC2", CTestInterfaceWebItf::cb_composite2 }, + { "SC3", CTestInterfaceWebItf::cb_composite3 }, + + }; + + arrayPtr = callbackArray; + arraySize = sizeofarray(callbackArray); + } + + static void _cbConnection(NLNET::TSockId from, void *arg) + { + H_AUTO(CTestInterfaceWeb__cbConnection); + CTestInterfaceWebItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterfaceWeb_Connection(from); + } + + static void _cbDisconnection(NLNET::TSockId from, void *arg) + { + H_AUTO(CTestInterfaceWeb__cbDisconnection); + CTestInterfaceWebItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterfaceWeb_Disconnection(from); + } + + + public: + /** Constructor, if you specify a replacement adaptor, then the object + * become owner of the adaptor (and it will be released with the + * interface). + */ + CTestInterfaceWebItf(ICallbackServerAdaptor *replacementAdaptor = NULL) + { + if (replacementAdaptor == NULL) + { + // use default callback server + _CallbackServer = std::auto_ptr(new CNelCallbackServerAdaptor(this)); + } + else + { + // use the replacement one + _CallbackServer = std::auto_ptr(replacementAdaptor); + } + } + + virtual ~CTestInterfaceWebItf() + { + } + + /// Open the interface socket in the specified port + void openItf(uint16 port) + { + NLNET::TCallbackItem *arrayPtr; + uint32 arraySize; + + + + getCallbakArray(arrayPtr, arraySize); + _CallbackServer->addCallbackArray(arrayPtr, arraySize); + + _CallbackServer->setConnectionCallback (_cbConnection, this); + _CallbackServer->setDisconnectionCallback (_cbDisconnection, this); + + _CallbackServer->init(port); + } + + /** Must be called evenly, update the network subclass to receive message + * and dispatch method invokation. + */ + void update() + { + H_AUTO(CTestInterfaceWeb_update); + + try + { + _CallbackServer->update(); + } + catch (...) + { + nlwarning("CTestInterfaceWeb : Exception launch in callback server update"); + } + } + + + void returnUInt32(NLNET::TSockId dest, uint32 i32) + { + H_AUTO(returnUInt32_returnUInt32); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::returnUInt32 called"); +#endif + NLNET::CMessage message("R32"); + nlWrite(message, serial, i32); + + _CallbackServer->send(message, dest); + } + + void returnUInt8(NLNET::TSockId dest, uint8 i8) + { + H_AUTO(returnUInt8_returnUInt8); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::returnUInt8 called"); +#endif + NLNET::CMessage message("R8"); + nlWrite(message, serial, i8); + + _CallbackServer->send(message, dest); + } + + void returnString(NLNET::TSockId dest, const std::string &str) + { + H_AUTO(returnString_returnString); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::returnString called"); +#endif + NLNET::CMessage message("RS"); + nlWrite(message, serial, const_cast < std::string& > (str)); + + _CallbackServer->send(message, dest); + } + + void returnComposite1(NLNET::TSockId dest, uint32 i32, uint8 i8, const std::string &str) + { + H_AUTO(returnComposite1_returnComposite1); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::returnComposite1 called"); +#endif + NLNET::CMessage message("RC1"); + nlWrite(message, serial, i32); + nlWrite(message, serial, i8); + nlWrite(message, serial, const_cast < std::string& > (str)); + + _CallbackServer->send(message, dest); + } + + void returnComposite2(NLNET::TSockId dest, const std::string &str1, const std::string &str2, const std::string &str3, const std::string &str4) + { + H_AUTO(returnComposite2_returnComposite2); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::returnComposite2 called"); +#endif + NLNET::CMessage message("RC2"); + nlWrite(message, serial, const_cast < std::string& > (str1)); + nlWrite(message, serial, const_cast < std::string& > (str2)); + nlWrite(message, serial, const_cast < std::string& > (str3)); + nlWrite(message, serial, const_cast < std::string& > (str4)); + + _CallbackServer->send(message, dest); + } + + void returnComposite3(NLNET::TSockId dest, uint8 i81, uint32 i321, const std::string &str1, uint8 i82, uint32 i322, const std::string &str2, uint8 i83, uint32 i323, const std::string &str3, uint8 i84, uint32 i324, const std::string &str4, uint32 i325, uint8 i85) + { + H_AUTO(returnComposite3_returnComposite3); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::returnComposite3 called"); +#endif + NLNET::CMessage message("RC3"); + nlWrite(message, serial, i81); + nlWrite(message, serial, i321); + nlWrite(message, serial, const_cast < std::string& > (str1)); + nlWrite(message, serial, i82); + nlWrite(message, serial, i322); + nlWrite(message, serial, const_cast < std::string& > (str2)); + nlWrite(message, serial, i83); + nlWrite(message, serial, i323); + nlWrite(message, serial, const_cast < std::string& > (str3)); + nlWrite(message, serial, i84); + nlWrite(message, serial, i324); + nlWrite(message, serial, const_cast < std::string& > (str4)); + nlWrite(message, serial, i325); + nlWrite(message, serial, i85); + + _CallbackServer->send(message, dest); + } + + static void cb_beginTest (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(beginTest_on_beginTest); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_beginTest received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_beginTest : calling on_beginTest"); +#endif + + + callback->on_beginTest(from); + + } + + static void cb_sendUInt32 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(sendUInt32_on_sendUInt32); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_sendUInt32 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 i32; + nlRead(message, serial, i32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_sendUInt32 : calling on_sendUInt32"); +#endif + + + callback->on_sendUInt32(from, i32); + + } + + static void cb_sendUInt8 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(sendUInt8_on_sendUInt8); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_sendUInt8 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint8 i8; + nlRead(message, serial, i8); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_sendUInt8 : calling on_sendUInt8"); +#endif + + + callback->on_sendUInt8(from, i8); + + } + + static void cb_sendString (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(sendString_on_sendString); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_sendString received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::string str; + nlRead(message, serial, str); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_sendString : calling on_sendString"); +#endif + + + callback->on_sendString(from, str); + + } + + static void cb_composite1 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(composite1_on_composite1); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_composite1 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 i32; + uint8 i8; + std::string str; + nlRead(message, serial, i32); + nlRead(message, serial, i8); + nlRead(message, serial, str); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_composite1 : calling on_composite1"); +#endif + + + callback->on_composite1(from, i32, i8, str); + + } + + static void cb_composite2 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(composite2_on_composite2); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_composite2 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::string str1; + std::string str2; + std::string str3; + std::string str4; + nlRead(message, serial, str1); + nlRead(message, serial, str2); + nlRead(message, serial, str3); + nlRead(message, serial, str4); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_composite2 : calling on_composite2"); +#endif + + + callback->on_composite2(from, str1, str2, str3, str4); + + } + + static void cb_composite3 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(composite3_on_composite3); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_composite3 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebItf *callback = (CTestInterfaceWebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint8 i81; + uint32 i321; + std::string str1; + uint8 i82; + uint32 i322; + std::string str2; + uint8 i83; + uint32 i323; + std::string str3; + uint8 i84; + uint32 i324; + std::string str4; + uint32 i325; + uint8 i85; + nlRead(message, serial, i81); + nlRead(message, serial, i321); + nlRead(message, serial, str1); + nlRead(message, serial, i82); + nlRead(message, serial, i322); + nlRead(message, serial, str2); + nlRead(message, serial, i83); + nlRead(message, serial, i323); + nlRead(message, serial, str3); + nlRead(message, serial, i84); + nlRead(message, serial, i324); + nlRead(message, serial, str4); + nlRead(message, serial, i325); + nlRead(message, serial, i85); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb::cb_composite3 : calling on_composite3"); +#endif + + + callback->on_composite3(from, i81, i321, str1, i82, i322, str2, i83, i323, str3, i84, i324, str4, i325, i85); + + } + + + /// Connection callback : a new interface client connect + virtual void on_CTestInterfaceWeb_Connection(NLNET::TSockId from) =0; + /// Disconnection callback : one of the interface client disconnect + virtual void on_CTestInterfaceWeb_Disconnection(NLNET::TSockId from) =0; + + + virtual void on_beginTest(NLNET::TSockId from) =0; + + virtual void on_sendUInt32(NLNET::TSockId from, uint32 i32) =0; + + virtual void on_sendUInt8(NLNET::TSockId from, uint8 i8) =0; + + virtual void on_sendString(NLNET::TSockId from, const std::string &str) =0; + + virtual void on_composite1(NLNET::TSockId from, uint32 i32, uint8 i8, const std::string &str) =0; + + virtual void on_composite2(NLNET::TSockId from, const std::string &str1, const std::string &str2, const std::string &str3, const std::string &str4) =0; + + virtual void on_composite3(NLNET::TSockId from, uint8 i81, uint32 i321, const std::string &str1, uint8 i82, uint32 i322, const std::string &str2, uint8 i83, uint32 i323, const std::string &str3, uint8 i84, uint32 i324, const std::string &str4, uint32 i325, uint8 i85) =0; + + }; + + // Test interface for web to C++ messaging + + /** This is the client side of the interface + * Derive from this class to invoke method on the callback server + */ + + class CTestInterfaceWebClientItf + { + protected: + + /// the callback client adaptor + std::auto_ptr < ICallbackClientAdaptor > _CallbackClient; + + + void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) + { + + static NLNET::TCallbackItem callbackArray[] = + { + { "R32", CTestInterfaceWebClientItf::cb_returnUInt32 }, + { "R8", CTestInterfaceWebClientItf::cb_returnUInt8 }, + { "RS", CTestInterfaceWebClientItf::cb_returnString }, + { "RC1", CTestInterfaceWebClientItf::cb_returnComposite1 }, + { "RC2", CTestInterfaceWebClientItf::cb_returnComposite2 }, + { "RC3", CTestInterfaceWebClientItf::cb_returnComposite3 }, + + }; + + arrayPtr = callbackArray; + arraySize = sizeofarray(callbackArray); + + } + + static void _cbDisconnection(NLNET::TSockId from, void *arg) + { + CTestInterfaceWebClientItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterfaceWebClient_Disconnection(from); + } + + + public: + /// Retreive the message name for a given callback name + static const std::string &getMessageName(const std::string &methodName) + { + static std::map messageNames; + static bool initialized = false; + if (!initialized) + { + messageNames.insert(std::make_pair(std::string("on_returnUInt32"), std::string("R32"))); + messageNames.insert(std::make_pair(std::string("on_returnUInt8"), std::string("R8"))); + messageNames.insert(std::make_pair(std::string("on_returnString"), std::string("RS"))); + messageNames.insert(std::make_pair(std::string("on_returnComposite1"), std::string("RC1"))); + messageNames.insert(std::make_pair(std::string("on_returnComposite2"), std::string("RC2"))); + messageNames.insert(std::make_pair(std::string("on_returnComposite3"), std::string("RC3"))); + + initialized = true; + } + + std::map < std::string, std::string>::const_iterator it(messageNames.find(methodName)); + if (it != messageNames.end()) + return it->second; + + + static std::string emptyString; + + return emptyString; + + } + + CTestInterfaceWebClientItf(ICallbackClientAdaptor *adaptorReplacement = NULL) + { + if (adaptorReplacement == NULL) + { + // use the default Nel adaptor + _CallbackClient = std::auto_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + } + else + { + // use the replacement one + _CallbackClient = std::auto_ptr < ICallbackClientAdaptor >(adaptorReplacement); + } + } + + /// Connect the interface client to the callback server at the specified address and port + virtual void connectItf(NLNET::CInetAddress address) + { + NLNET::TCallbackItem *arrayPtr; + uint32 arraySize; + + static bool callbackAdded = false; + if (!callbackAdded) + { + + getCallbakArray(arrayPtr, arraySize); + _CallbackClient->addCallbackArray(arrayPtr, arraySize); + } + + _CallbackClient->setDisconnectionCallback (_cbDisconnection, this); + + _CallbackClient->connect(address); + } + + /** Must be called evenly, update the network subclass to receive message + * and dispatch invokation returns. + */ + virtual void update() + { + H_AUTO(CTestInterfaceWeb_update); + + try + { + _CallbackClient->update(); + } + catch (...) + { + nlwarning("CTestInterfaceWeb : Exception launch in callback client update"); + } + } + + + void beginTest() + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::beginTest called"); +#endif + NLNET::CMessage message("BT"); + + _CallbackClient->send(message); + } + + void sendUInt32(uint32 i32) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::sendUInt32 called"); +#endif + NLNET::CMessage message("S32"); + nlWrite(message, serial, i32); + + _CallbackClient->send(message); + } + + void sendUInt8(uint8 i8) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::sendUInt8 called"); +#endif + NLNET::CMessage message("S8"); + nlWrite(message, serial, i8); + + _CallbackClient->send(message); + } + + void sendString(const std::string &str) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::sendString called"); +#endif + NLNET::CMessage message("SS"); + nlWrite(message, serial, const_cast < std::string& > (str)); + + _CallbackClient->send(message); + } + + void composite1(uint32 i32, uint8 i8, const std::string &str) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::composite1 called"); +#endif + NLNET::CMessage message("SC1"); + nlWrite(message, serial, i32); + nlWrite(message, serial, i8); + nlWrite(message, serial, const_cast < std::string& > (str)); + + _CallbackClient->send(message); + } + + void composite2(const std::string &str1, const std::string &str2, const std::string &str3, const std::string &str4) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::composite2 called"); +#endif + NLNET::CMessage message("SC2"); + nlWrite(message, serial, const_cast < std::string& > (str1)); + nlWrite(message, serial, const_cast < std::string& > (str2)); + nlWrite(message, serial, const_cast < std::string& > (str3)); + nlWrite(message, serial, const_cast < std::string& > (str4)); + + _CallbackClient->send(message); + } + + void composite3(uint8 i81, uint32 i321, const std::string &str1, uint8 i82, uint32 i322, const std::string &str2, uint8 i83, uint32 i323, const std::string &str3, uint8 i84, uint32 i324, const std::string &str4, uint32 i325, uint8 i85) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::composite3 called"); +#endif + NLNET::CMessage message("SC3"); + nlWrite(message, serial, i81); + nlWrite(message, serial, i321); + nlWrite(message, serial, const_cast < std::string& > (str1)); + nlWrite(message, serial, i82); + nlWrite(message, serial, i322); + nlWrite(message, serial, const_cast < std::string& > (str2)); + nlWrite(message, serial, i83); + nlWrite(message, serial, i323); + nlWrite(message, serial, const_cast < std::string& > (str3)); + nlWrite(message, serial, i84); + nlWrite(message, serial, i324); + nlWrite(message, serial, const_cast < std::string& > (str4)); + nlWrite(message, serial, i325); + nlWrite(message, serial, i85); + + _CallbackClient->send(message); + } + + static void cb_returnUInt32 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnUInt32 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebClientItf *callback = (CTestInterfaceWebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 i32; + nlRead(message, serial, i32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnUInt32 : calling on_returnUInt32"); +#endif + + callback->on_returnUInt32(from, i32); + } + + static void cb_returnUInt8 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnUInt8 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebClientItf *callback = (CTestInterfaceWebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint8 i8; + nlRead(message, serial, i8); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnUInt8 : calling on_returnUInt8"); +#endif + + callback->on_returnUInt8(from, i8); + } + + static void cb_returnString (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnString received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebClientItf *callback = (CTestInterfaceWebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::string str; + nlRead(message, serial, str); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnString : calling on_returnString"); +#endif + + callback->on_returnString(from, str); + } + + static void cb_returnComposite1 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnComposite1 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebClientItf *callback = (CTestInterfaceWebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 i32; + uint8 i8; + std::string str; + nlRead(message, serial, i32); + nlRead(message, serial, i8); + nlRead(message, serial, str); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnComposite1 : calling on_returnComposite1"); +#endif + + callback->on_returnComposite1(from, i32, i8, str); + } + + static void cb_returnComposite2 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnComposite2 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebClientItf *callback = (CTestInterfaceWebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::string str1; + std::string str2; + std::string str3; + std::string str4; + nlRead(message, serial, str1); + nlRead(message, serial, str2); + nlRead(message, serial, str3); + nlRead(message, serial, str4); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnComposite2 : calling on_returnComposite2"); +#endif + + callback->on_returnComposite2(from, str1, str2, str3, str4); + } + + static void cb_returnComposite3 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnComposite3 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWebClientItf *callback = (CTestInterfaceWebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint8 i81; + uint32 i321; + std::string str1; + uint8 i82; + uint32 i322; + std::string str2; + uint8 i83; + uint32 i323; + std::string str3; + uint8 i84; + uint32 i324; + std::string str4; + uint32 i325; + uint8 i85; + nlRead(message, serial, i81); + nlRead(message, serial, i321); + nlRead(message, serial, str1); + nlRead(message, serial, i82); + nlRead(message, serial, i322); + nlRead(message, serial, str2); + nlRead(message, serial, i83); + nlRead(message, serial, i323); + nlRead(message, serial, str3); + nlRead(message, serial, i84); + nlRead(message, serial, i324); + nlRead(message, serial, str4); + nlRead(message, serial, i325); + nlRead(message, serial, i85); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWebClient::cb_returnComposite3 : calling on_returnComposite3"); +#endif + + callback->on_returnComposite3(from, i81, i321, str1, i82, i322, str2, i83, i323, str3, i84, i324, str4, i325, i85); + } + + + /// Disconnection callback : the connection to the server is lost + virtual void on_CTestInterfaceWebClient_Disconnection(NLNET::TSockId from) =0; + + + virtual void on_returnUInt32(NLNET::TSockId from, uint32 i32) =0; + + virtual void on_returnUInt8(NLNET::TSockId from, uint8 i8) =0; + + virtual void on_returnString(NLNET::TSockId from, const std::string &str) =0; + + virtual void on_returnComposite1(NLNET::TSockId from, uint32 i32, uint8 i8, const std::string &str) =0; + + virtual void on_returnComposite2(NLNET::TSockId from, const std::string &str1, const std::string &str2, const std::string &str3, const std::string &str4) =0; + + virtual void on_returnComposite3(NLNET::TSockId from, uint8 i81, uint32 i321, const std::string &str1, uint8 i82, uint32 i322, const std::string &str2, uint8 i83, uint32 i323, const std::string &str3, uint8 i84, uint32 i324, const std::string &str4, uint32 i325, uint8 i85) =0; + + }; + // a second interface to stress the generator + + class CTestInterface2WebItf + { + protected: + + /// the callback server adaptor + std::auto_ptr _CallbackServer; + + void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) + { + static NLNET::TCallbackItem callbackArray[] = + { + { "S322", CTestInterface2WebItf::cb_sendInt32_2 }, + + }; + + arrayPtr = callbackArray; + arraySize = sizeofarray(callbackArray); + } + + static void _cbConnection(NLNET::TSockId from, void *arg) + { + H_AUTO(CTestInterface2Web__cbConnection); + CTestInterface2WebItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterface2Web_Connection(from); + } + + static void _cbDisconnection(NLNET::TSockId from, void *arg) + { + H_AUTO(CTestInterface2Web__cbDisconnection); + CTestInterface2WebItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterface2Web_Disconnection(from); + } + + + public: + /** Constructor, if you specify a replacement adaptor, then the object + * become owner of the adaptor (and it will be released with the + * interface). + */ + CTestInterface2WebItf(ICallbackServerAdaptor *replacementAdaptor = NULL) + { + if (replacementAdaptor == NULL) + { + // use default callback server + _CallbackServer = std::auto_ptr(new CNelCallbackServerAdaptor(this)); + } + else + { + // use the replacement one + _CallbackServer = std::auto_ptr(replacementAdaptor); + } + } + + virtual ~CTestInterface2WebItf() + { + } + + /// Open the interface socket in the specified port + void openItf(uint16 port) + { + NLNET::TCallbackItem *arrayPtr; + uint32 arraySize; + + + + getCallbakArray(arrayPtr, arraySize); + _CallbackServer->addCallbackArray(arrayPtr, arraySize); + + _CallbackServer->setConnectionCallback (_cbConnection, this); + _CallbackServer->setDisconnectionCallback (_cbDisconnection, this); + + _CallbackServer->init(port); + } + + /** Must be called evenly, update the network subclass to receive message + * and dispatch method invokation. + */ + void update() + { + H_AUTO(CTestInterface2Web_update); + + try + { + _CallbackServer->update(); + } + catch (...) + { + nlwarning("CTestInterface2Web : Exception launch in callback server update"); + } + } + + + void returnInt32_2(NLNET::TSockId dest, uint32 i32) + { + H_AUTO(returnInt32_2_returnInt32_2); +#ifdef NL_DEBUG + nldebug("CTestInterface2Web::returnInt32_2 called"); +#endif + NLNET::CMessage message("R322"); + nlWrite(message, serial, i32); + + _CallbackServer->send(message, dest); + } + + static void cb_sendInt32_2 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(sendInt32_2_on_sendInt32_2); +#ifdef NL_DEBUG + nldebug("CTestInterface2Web::cb_sendInt32_2 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterface2WebItf *callback = (CTestInterface2WebItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 i32; + nlRead(message, serial, i32); + + +#ifdef NL_DEBUG + nldebug("CTestInterface2Web::cb_sendInt32_2 : calling on_sendInt32_2"); +#endif + + + callback->on_sendInt32_2(from, i32); + + } + + + /// Connection callback : a new interface client connect + virtual void on_CTestInterface2Web_Connection(NLNET::TSockId from) =0; + /// Disconnection callback : one of the interface client disconnect + virtual void on_CTestInterface2Web_Disconnection(NLNET::TSockId from) =0; + + + virtual void on_sendInt32_2(NLNET::TSockId from, uint32 i32) =0; + + }; + + // a second interface to stress the generator + + /** This is the client side of the interface + * Derive from this class to invoke method on the callback server + */ + + class CTestInterface2WebClientItf + { + protected: + + /// the callback client adaptor + std::auto_ptr < ICallbackClientAdaptor > _CallbackClient; + + + void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) + { + + static NLNET::TCallbackItem callbackArray[] = + { + { "R322", CTestInterface2WebClientItf::cb_returnInt32_2 }, + + }; + + arrayPtr = callbackArray; + arraySize = sizeofarray(callbackArray); + + } + + static void _cbDisconnection(NLNET::TSockId from, void *arg) + { + CTestInterface2WebClientItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterface2WebClient_Disconnection(from); + } + + + public: + /// Retreive the message name for a given callback name + static const std::string &getMessageName(const std::string &methodName) + { + static std::map messageNames; + static bool initialized = false; + if (!initialized) + { + messageNames.insert(std::make_pair(std::string("on_returnInt32_2"), std::string("R322"))); + + initialized = true; + } + + std::map < std::string, std::string>::const_iterator it(messageNames.find(methodName)); + if (it != messageNames.end()) + return it->second; + + + static std::string emptyString; + + return emptyString; + + } + + CTestInterface2WebClientItf(ICallbackClientAdaptor *adaptorReplacement = NULL) + { + if (adaptorReplacement == NULL) + { + // use the default Nel adaptor + _CallbackClient = std::auto_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + } + else + { + // use the replacement one + _CallbackClient = std::auto_ptr < ICallbackClientAdaptor >(adaptorReplacement); + } + } + + /// Connect the interface client to the callback server at the specified address and port + virtual void connectItf(NLNET::CInetAddress address) + { + NLNET::TCallbackItem *arrayPtr; + uint32 arraySize; + + static bool callbackAdded = false; + if (!callbackAdded) + { + + getCallbakArray(arrayPtr, arraySize); + _CallbackClient->addCallbackArray(arrayPtr, arraySize); + } + + _CallbackClient->setDisconnectionCallback (_cbDisconnection, this); + + _CallbackClient->connect(address); + } + + /** Must be called evenly, update the network subclass to receive message + * and dispatch invokation returns. + */ + virtual void update() + { + H_AUTO(CTestInterface2Web_update); + + try + { + _CallbackClient->update(); + } + catch (...) + { + nlwarning("CTestInterface2Web : Exception launch in callback client update"); + } + } + + + void sendInt32_2(uint32 i32) + { +#ifdef NL_DEBUG + nldebug("CTestInterface2WebClient::sendInt32_2 called"); +#endif + NLNET::CMessage message("S322"); + nlWrite(message, serial, i32); + + _CallbackClient->send(message); + } + + static void cb_returnInt32_2 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterface2WebClient::cb_returnInt32_2 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterface2WebClientItf *callback = (CTestInterface2WebClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 i32; + nlRead(message, serial, i32); + + +#ifdef NL_DEBUG + nldebug("CTestInterface2WebClient::cb_returnInt32_2 : calling on_returnInt32_2"); +#endif + + callback->on_returnInt32_2(from, i32); + } + + + /// Disconnection callback : the connection to the server is lost + virtual void on_CTestInterface2WebClient_Disconnection(NLNET::TSockId from) =0; + + + virtual void on_returnInt32_2(NLNET::TSockId from, uint32 i32) =0; + + }; + + + struct TEnum + { + enum TValues + { + enum_a, + enum_b, + enum_c, + + invalid + }; + + static const NLMISC::CStringConversion &getConversionTable() + { + NL_BEGIN_STRING_CONVERSION_TABLE(TValues) + NL_STRING_CONVERSION_TABLE_ENTRY(enum_a) + NL_STRING_CONVERSION_TABLE_ENTRY(enum_b) + NL_STRING_CONVERSION_TABLE_ENTRY(enum_c) + NL_STRING_CONVERSION_TABLE_ENTRY(invalid) + }; + static NLMISC::CStringConversion + conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table) + / sizeof(TValues_nl_string_conversion_table[0]), invalid); + + return conversionTable; + } + + TValues _Value; + + public: + TEnum() + : _Value(invalid) + { + } + TEnum(TValues value) + : _Value(value) + { + } + + TEnum(const std::string &str) + { + _Value = getConversionTable().fromString(str); + } + + void serial(NLMISC::IStream &s) + { + s.serialEnum(_Value); + } + + bool operator == (const TEnum &other) const + { + return _Value == other._Value; + } + bool operator != (const TEnum &other) const + { + return ! (_Value == other._Value); + } + bool operator < (const TEnum &other) const + { + return _Value < other._Value; + } + + const std::string &toString() const + { + return getConversionTable().toString(_Value); + } + static const std::string &toString(TValues value) + { + return getConversionTable().toString(value); + } + + TValues getValue() const + { + return _Value; + } + + + }; + + class CTestInterfaceWeb2Itf + { + protected: + + /// the callback server adaptor + std::auto_ptr _CallbackServer; + + void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) + { + static NLNET::TCallbackItem callbackArray[] = + { + { "SV32", CTestInterfaceWeb2Itf::cb_sendVectorUInt32 }, + { "SVS", CTestInterfaceWeb2Itf::cb_sendVectorString }, + { "TWC", CTestInterfaceWeb2Itf::cb_twoWayCall }, + { "TWCI", CTestInterfaceWeb2Itf::cb_twoWayCallInt }, + { "TWCE", CTestInterfaceWeb2Itf::cb_twoWayCallEnum }, + { "TWCV", CTestInterfaceWeb2Itf::cb_twoWayCallVector }, + { "MVI", CTestInterfaceWeb2Itf::cb_mixedVector }, + { "TWMV", CTestInterfaceWeb2Itf::cb_mixedTwoWayVector }, + + }; + + arrayPtr = callbackArray; + arraySize = sizeofarray(callbackArray); + } + + static void _cbConnection(NLNET::TSockId from, void *arg) + { + H_AUTO(CTestInterfaceWeb2__cbConnection); + CTestInterfaceWeb2Itf *_this = reinterpret_cast(arg); + + _this->on_CTestInterfaceWeb2_Connection(from); + } + + static void _cbDisconnection(NLNET::TSockId from, void *arg) + { + H_AUTO(CTestInterfaceWeb2__cbDisconnection); + CTestInterfaceWeb2Itf *_this = reinterpret_cast(arg); + + _this->on_CTestInterfaceWeb2_Disconnection(from); + } + + + public: + /** Constructor, if you specify a replacement adaptor, then the object + * become owner of the adaptor (and it will be released with the + * interface). + */ + CTestInterfaceWeb2Itf(ICallbackServerAdaptor *replacementAdaptor = NULL) + { + if (replacementAdaptor == NULL) + { + // use default callback server + _CallbackServer = std::auto_ptr(new CNelCallbackServerAdaptor(this)); + } + else + { + // use the replacement one + _CallbackServer = std::auto_ptr(replacementAdaptor); + } + } + + virtual ~CTestInterfaceWeb2Itf() + { + } + + /// Open the interface socket in the specified port + void openItf(uint16 port) + { + NLNET::TCallbackItem *arrayPtr; + uint32 arraySize; + + + + getCallbakArray(arrayPtr, arraySize); + _CallbackServer->addCallbackArray(arrayPtr, arraySize); + + _CallbackServer->setConnectionCallback (_cbConnection, this); + _CallbackServer->setDisconnectionCallback (_cbDisconnection, this); + + _CallbackServer->init(port); + } + + /** Must be called evenly, update the network subclass to receive message + * and dispatch method invokation. + */ + void update() + { + H_AUTO(CTestInterfaceWeb2_update); + + try + { + _CallbackServer->update(); + } + catch (...) + { + nlwarning("CTestInterfaceWeb2 : Exception launch in callback server update"); + } + } + + + void returnVectorUInt32(NLNET::TSockId dest, const std::vector &i32) + { + H_AUTO(returnVectorUInt32_returnVectorUInt32); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::returnVectorUInt32 called"); +#endif + NLNET::CMessage message("RV32"); + nlWrite(message, serialCont, i32); + + _CallbackServer->send(message, dest); + } + + void returnVectorString(NLNET::TSockId dest, const std::vector &vstr) + { + H_AUTO(returnVectorString_returnVectorString); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::returnVectorString called"); +#endif + NLNET::CMessage message("RVS"); + nlWrite(message, serialCont, vstr); + + _CallbackServer->send(message, dest); + } + + void returnMixedVector(NLNET::TSockId dest, uint32 param1, const std::vector &vstr, const std::vector &vi32) + { + H_AUTO(returnMixedVector_returnMixedVector); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::returnMixedVector called"); +#endif + NLNET::CMessage message("RMVI"); + nlWrite(message, serial, param1); + nlWrite(message, serialCont, vstr); + nlWrite(message, serialCont, vi32); + + _CallbackServer->send(message, dest); + } + + static void cb_sendVectorUInt32 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(sendVectorUInt32_on_sendVectorUInt32); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_sendVectorUInt32 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::vector vi32; + nlRead(message, serialCont, vi32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_sendVectorUInt32 : calling on_sendVectorUInt32"); +#endif + + + callback->on_sendVectorUInt32(from, vi32); + + } + + static void cb_sendVectorString (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(sendVectorString_on_sendVectorString); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_sendVectorString received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::vector vstr; + nlRead(message, serialCont, vstr); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_sendVectorString : calling on_sendVectorString"); +#endif + + + callback->on_sendVectorString(from, vstr); + + } + + static void cb_twoWayCall (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(twoWayCall_on_twoWayCall); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCall received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::string param; + nlRead(message, serial, param); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCall : calling on_twoWayCall"); +#endif + + std::string retValue; + + retValue = callback->on_twoWayCall(from, param); + + NLNET::CMessage retMsg("R_TWC"); + + nlWrite(retMsg, serial, retValue); + + + callback->_CallbackServer->send(retMsg, from); + + } + + static void cb_twoWayCallInt (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(twoWayCallInt_on_twoWayCallInt); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCallInt received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 param; + nlRead(message, serial, param); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCallInt : calling on_twoWayCallInt"); +#endif + + uint32 retValue; + + retValue = callback->on_twoWayCallInt(from, param); + + NLNET::CMessage retMsg("R_TWCI"); + + nlWrite(retMsg, serial, retValue); + + + callback->_CallbackServer->send(retMsg, from); + + } + + static void cb_twoWayCallEnum (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(twoWayCallEnum_on_twoWayCallEnum); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCallEnum received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + TEnum param; + nlRead(message, serial, param); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCallEnum : calling on_twoWayCallEnum"); +#endif + + TEnum retValue; + + retValue = callback->on_twoWayCallEnum(from, param); + + NLNET::CMessage retMsg("R_TWCE"); + + nlWrite(retMsg, serial, retValue); + + + callback->_CallbackServer->send(retMsg, from); + + } + + static void cb_twoWayCallVector (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(twoWayCallVector_on_twoWayCallVector); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCallVector received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::vector param; + nlRead(message, serialCont, param); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_twoWayCallVector : calling on_twoWayCallVector"); +#endif + + std::vector retValue; + + retValue = callback->on_twoWayCallVector(from, param); + + NLNET::CMessage retMsg("R_TWCV"); + + nlWrite(retMsg, serialCont, retValue); + + + callback->_CallbackServer->send(retMsg, from); + + } + + static void cb_mixedVector (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(mixedVector_on_mixedVector); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_mixedVector received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 param1; + std::vector vstr; + std::vector vi32; + nlRead(message, serial, param1); + nlRead(message, serialCont, vstr); + nlRead(message, serialCont, vi32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_mixedVector : calling on_mixedVector"); +#endif + + + callback->on_mixedVector(from, param1, vstr, vi32); + + } + + static void cb_mixedTwoWayVector (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { + H_AUTO(mixedTwoWayVector_on_mixedTwoWayVector); +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_mixedTwoWayVector received from class '%s'", typeid(netbase).name()); +#endif + ICallbackServerAdaptor *adaptor = static_cast< ICallbackServerAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2Itf *callback = (CTestInterfaceWeb2Itf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 param1; + std::vector vstr; + std::vector vi32; + nlRead(message, serial, param1); + nlRead(message, serialCont, vstr); + nlRead(message, serialCont, vi32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2::cb_mixedTwoWayVector : calling on_mixedTwoWayVector"); +#endif + + uint32 retValue; + + retValue = callback->on_mixedTwoWayVector(from, param1, vstr, vi32); + + NLNET::CMessage retMsg("R_TWMV"); + + nlWrite(retMsg, serial, retValue); + + + callback->_CallbackServer->send(retMsg, from); + + } + + + /// Connection callback : a new interface client connect + virtual void on_CTestInterfaceWeb2_Connection(NLNET::TSockId from) =0; + /// Disconnection callback : one of the interface client disconnect + virtual void on_CTestInterfaceWeb2_Disconnection(NLNET::TSockId from) =0; + + + virtual void on_sendVectorUInt32(NLNET::TSockId from, const std::vector &vi32) =0; + + virtual void on_sendVectorString(NLNET::TSockId from, const std::vector &vstr) =0; + + virtual std::string on_twoWayCall(NLNET::TSockId from, const std::string ¶m) =0; + + virtual uint32 on_twoWayCallInt(NLNET::TSockId from, uint32 param) =0; + + virtual TEnum on_twoWayCallEnum(NLNET::TSockId from, TEnum param) =0; + + virtual std::vector on_twoWayCallVector(NLNET::TSockId from, const std::vector ¶m) =0; + + virtual void on_mixedVector(NLNET::TSockId from, uint32 param1, const std::vector &vstr, const std::vector &vi32) =0; + + virtual uint32 on_mixedTwoWayVector(NLNET::TSockId from, uint32 param1, const std::vector &vstr, const std::vector &vi32) =0; + + }; + + + /** This is the client side of the interface + * Derive from this class to invoke method on the callback server + */ + + class CTestInterfaceWeb2ClientItf + { + protected: + + /// the callback client adaptor + std::auto_ptr < ICallbackClientAdaptor > _CallbackClient; + + + void getCallbakArray(NLNET::TCallbackItem *&arrayPtr, uint32 &arraySize) + { + + static NLNET::TCallbackItem callbackArray[] = + { + { "RV32", CTestInterfaceWeb2ClientItf::cb_returnVectorUInt32 }, + { "RVS", CTestInterfaceWeb2ClientItf::cb_returnVectorString }, + { "RMVI", CTestInterfaceWeb2ClientItf::cb_returnMixedVector }, + + }; + + arrayPtr = callbackArray; + arraySize = sizeofarray(callbackArray); + + } + + static void _cbDisconnection(NLNET::TSockId from, void *arg) + { + CTestInterfaceWeb2ClientItf *_this = reinterpret_cast(arg); + + _this->on_CTestInterfaceWeb2Client_Disconnection(from); + } + + + public: + /// Retreive the message name for a given callback name + static const std::string &getMessageName(const std::string &methodName) + { + static std::map messageNames; + static bool initialized = false; + if (!initialized) + { + messageNames.insert(std::make_pair(std::string("on_returnVectorUInt32"), std::string("RV32"))); + messageNames.insert(std::make_pair(std::string("on_returnVectorString"), std::string("RVS"))); + messageNames.insert(std::make_pair(std::string("on_returnMixedVector"), std::string("RMVI"))); + + initialized = true; + } + + std::map < std::string, std::string>::const_iterator it(messageNames.find(methodName)); + if (it != messageNames.end()) + return it->second; + + + static std::string emptyString; + + return emptyString; + + } + + CTestInterfaceWeb2ClientItf(ICallbackClientAdaptor *adaptorReplacement = NULL) + { + if (adaptorReplacement == NULL) + { + // use the default Nel adaptor + _CallbackClient = std::auto_ptr < ICallbackClientAdaptor >(new CNelCallbackClientAdaptor(this)); + } + else + { + // use the replacement one + _CallbackClient = std::auto_ptr < ICallbackClientAdaptor >(adaptorReplacement); + } + } + + /// Connect the interface client to the callback server at the specified address and port + virtual void connectItf(NLNET::CInetAddress address) + { + NLNET::TCallbackItem *arrayPtr; + uint32 arraySize; + + static bool callbackAdded = false; + if (!callbackAdded) + { + + getCallbakArray(arrayPtr, arraySize); + _CallbackClient->addCallbackArray(arrayPtr, arraySize); + } + + _CallbackClient->setDisconnectionCallback (_cbDisconnection, this); + + _CallbackClient->connect(address); + } + + /** Must be called evenly, update the network subclass to receive message + * and dispatch invokation returns. + */ + virtual void update() + { + H_AUTO(CTestInterfaceWeb2_update); + + try + { + _CallbackClient->update(); + } + catch (...) + { + nlwarning("CTestInterfaceWeb2 : Exception launch in callback client update"); + } + } + + + void sendVectorUInt32(const std::vector &vi32) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::sendVectorUInt32 called"); +#endif + NLNET::CMessage message("SV32"); + nlWrite(message, serialCont, vi32); + + _CallbackClient->send(message); + } + + void sendVectorString(const std::vector &vstr) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::sendVectorString called"); +#endif + NLNET::CMessage message("SVS"); + nlWrite(message, serialCont, vstr); + + _CallbackClient->send(message); + } + + void twoWayCall(const std::string ¶m) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::twoWayCall called"); +#endif + NLNET::CMessage message("TWC"); + nlWrite(message, serial, const_cast < std::string& > (param)); + + _CallbackClient->send(message); + } + + void twoWayCallInt(uint32 param) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::twoWayCallInt called"); +#endif + NLNET::CMessage message("TWCI"); + nlWrite(message, serial, param); + + _CallbackClient->send(message); + } + + void twoWayCallEnum(TEnum param) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::twoWayCallEnum called"); +#endif + NLNET::CMessage message("TWCE"); + nlWrite(message, serial, param); + + _CallbackClient->send(message); + } + + void twoWayCallVector(const std::vector ¶m) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::twoWayCallVector called"); +#endif + NLNET::CMessage message("TWCV"); + nlWrite(message, serialCont, param); + + _CallbackClient->send(message); + } + + void mixedVector(uint32 param1, const std::vector &vstr, const std::vector &vi32) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::mixedVector called"); +#endif + NLNET::CMessage message("MVI"); + nlWrite(message, serial, param1); + nlWrite(message, serialCont, vstr); + nlWrite(message, serialCont, vi32); + + _CallbackClient->send(message); + } + + void mixedTwoWayVector(uint32 param1, const std::vector &vstr, const std::vector &vi32) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::mixedTwoWayVector called"); +#endif + NLNET::CMessage message("TWMV"); + nlWrite(message, serial, param1); + nlWrite(message, serialCont, vstr); + nlWrite(message, serialCont, vi32); + + _CallbackClient->send(message); + } + + static void cb_returnVectorUInt32 (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::cb_returnVectorUInt32 received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2ClientItf *callback = (CTestInterfaceWeb2ClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::vector i32; + nlRead(message, serialCont, i32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::cb_returnVectorUInt32 : calling on_returnVectorUInt32"); +#endif + + callback->on_returnVectorUInt32(from, i32); + } + + static void cb_returnVectorString (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::cb_returnVectorString received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2ClientItf *callback = (CTestInterfaceWeb2ClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + std::vector vstr; + nlRead(message, serialCont, vstr); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::cb_returnVectorString : calling on_returnVectorString"); +#endif + + callback->on_returnVectorString(from, vstr); + } + + static void cb_returnMixedVector (NLNET::CMessage &message, NLNET::TSockId from, NLNET::CCallbackNetBase &netbase) + { +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::cb_returnMixedVector received from class '%s'", typeid(netbase).name()); +#endif + ICallbackClientAdaptor *adaptor = static_cast< ICallbackClientAdaptor *>(netbase.getUserData()); + + CTestInterfaceWeb2ClientItf *callback = (CTestInterfaceWeb2ClientItf *)adaptor->getContainerClass(); + + if (callback == NULL) + return; + uint32 param1; + std::vector vstr; + std::vector vi32; + nlRead(message, serial, param1); + nlRead(message, serialCont, vstr); + nlRead(message, serialCont, vi32); + + +#ifdef NL_DEBUG + nldebug("CTestInterfaceWeb2Client::cb_returnMixedVector : calling on_returnMixedVector"); +#endif + + callback->on_returnMixedVector(from, param1, vstr, vi32); + } + + + /// Disconnection callback : the connection to the server is lost + virtual void on_CTestInterfaceWeb2Client_Disconnection(NLNET::TSockId from) =0; + + + virtual void on_returnVectorUInt32(NLNET::TSockId from, const std::vector &i32) =0; + + virtual void on_returnVectorString(NLNET::TSockId from, const std::vector &vstr) =0; + + virtual void on_returnMixedVector(NLNET::TSockId from, uint32 param1, const std::vector &vstr, const std::vector &vi32) =0; + + }; + +} + +#endif diff --git a/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.xml b/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.xml new file mode 100644 index 000000000..eb7c1fa9e --- /dev/null +++ b/code/ryzom/tools/server/test_web_interface/test_web_interface_itf.xml @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/www/admin.php b/code/ryzom/tools/server/www/admin.php new file mode 100644 index 000000000..c8bea7e3d --- /dev/null +++ b/code/ryzom/tools/server/www/admin.php @@ -0,0 +1,70 @@ +\n"; + recover_thread($recover_forum); + die(); +} + +importParam('recover_thread'); +importParam('recover_threadthread'); +if ($recover_thread && isset($recover_threadthread)) +{ + echo "recover forum $recover_thread
\n"; + recover_one_thread($recover_thread, $recover_threadthread); + die(); +} + +importParam('rename_forum'); +importParam('into_forum'); +if ($rename_forum) +{ + echo "rename forum $rename_forum into $into_forum
\n"; + rename_forum($rename_forum, $into_forum); + die(); +} + + +importParam('shard'); + +importParam('mailbox'); +importParam('mail'); + +if ($mail) +{ + $mdir = get_user_dir($mailbox, $shard); + readfile($mdir.$mail); + die(); +} +else if ($mailbox) +{ + display_mailbox_content($shard, $mailbox); + die(); +} + +importParam('forum'); +importParam('thread'); + +if ($thread) +{ + display_thread_content($shard, $forum, $thread); + die(); +} +else if ($forum) +{ + display_forum_content($shard, $forum); + die(); +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/www/admin_interface.php b/code/ryzom/tools/server/www/admin_interface.php new file mode 100644 index 000000000..cf549334f --- /dev/null +++ b/code/ryzom/tools/server/www/admin_interface.php @@ -0,0 +1,103 @@ +\n"; +echo "SHARD:
\n"; +echo "MAILBOX:
\n"; +echo "FORUM:
\n"; +echo "
\n"; +echo "\n"; + +if ($_GET["mailbox"]) +{ + echo "Get mailbox ".$_GET["mailbox"]." content:
\n"; + $s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port"); + fputs($s,"GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&mailbox=".$_GET["mailbox"]." HTTP/1.0\n\n"); + + while(!feof($s)) + { + $l = trim(fgets($s, 2048)); + if (ereg("^FILE:(.*)", $l, $reg)) + echo "".$reg[1]."
\n"; + } + + fclose($s); + echo "

\n"; +} + +if ($_GET["mail"]) +{ + echo "Get mail ".$_GET["mailbox"]."/".$_GET["mail"]." content:
\n"; + $s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port"); + fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&mail=".$_GET["mail"]."&mailbox=".$_GET["mailbox"]." HTTP/1.0\n\n"); + + echo "Content of mail:
\n"; + while(!feof($s)) + echo nl2br(htmlentities(trim(fgets($s, 2048)))); + + fclose($s); + echo "

\n"; +} + +if ($_GET["recover_thread"]) +{ + echo "Recover thread ".$_GET["forum"]." ".$_GET["recover_thread"]."
\n"; + $s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port"); + fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&recover_thread=".$_GET["forum"]."&recover_threadthread=".$_GET["recover_thread"]." HTTP/1.0\n\n"); + fclose($s); + echo "

\n"; +} + +if ($_GET["forum"]) +{ + echo "Get forum ".$_GET["forum"]." content:
\n"; + $s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port"); + fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&forum=".$_GET["forum"]." HTTP/1.0\n\n"); + + while(!feof($s)) + { + $l = trim(fgets($s, 2048)); + if (ereg("^FILE:(.*)", $l, $reg)) + { + echo "".trim($reg[1])."\n"; + if ($reg[1]{0} == '_') + { + echo " recover thread\n"; + } + echo "
\n"; + } + } + + fclose($s); + echo "

\n"; +} + +if ($_GET["thread"]) +{ + echo "Get thread ".$_GET["forum"]."/".$_GET["thread"]." content:
\n"; + $s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port"); + fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&thread=".$_GET["thread"]." HTTP/1.0\n\n"); + + echo "Content of thread:
\n"; + while(!feof($s)) + { + $l = trim(fgets($s, 2048)); + if (ereg("^TOPIC:(.*) SUBMIT:(.*)$", $l, $reg)) + echo nl2br(htmlentities(" TOPIC:".$reg[1]."SUBMITED BY: ".$reg[2]."\n")); + if (ereg("^AUTHOR:(.*) DATE:(.*) POST:(.*)", $l, $reg)) + echo nl2br(htmlentities("AUTHOR: ".$reg[1]." DATE:".$reg[2]." POST:".$reg[3]."\n")); + } + + fclose($s); + echo "

\n"; +} + + + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/www/admin_utils.php b/code/ryzom/tools/server/www/admin_utils.php new file mode 100644 index 000000000..293d6a299 --- /dev/null +++ b/code/ryzom/tools/server/www/admin_utils.php @@ -0,0 +1,46 @@ + 0) + { + foreach ($array as $post) + { + echo "AUTHOR: ".$post[0]." DATE: ".$post[2]." POST: ".$post[1]."\n"; + } + } + echo "-- END THREAD $forum $thread\n"; +} + +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/www/check_mail.php b/code/ryzom/tools/server/www/check_mail.php new file mode 100644 index 000000000..0929de6b0 --- /dev/null +++ b/code/ryzom/tools/server/www/check_mail.php @@ -0,0 +1,21 @@ + diff --git a/code/ryzom/tools/server/www/config.php b/code/ryzom/tools/server/www/config.php new file mode 100644 index 000000000..c525f9b13 --- /dev/null +++ b/code/ryzom/tools/server/www/config.php @@ -0,0 +1,6 @@ + diff --git a/code/ryzom/tools/server/www/confirm_remove_mail.php b/code/ryzom/tools/server/www/confirm_remove_mail.php new file mode 100644 index 000000000..a110fc2dd --- /dev/null +++ b/code/ryzom/tools/server/www/confirm_remove_mail.php @@ -0,0 +1,31 @@ + $value) + { + if (matchParam($var, "select_mail_", $mail)) + { + $mails[] = $mail; + $selected_mails .= "\n"; + } + } + + // + + $instance = str_replace(array('%%MAIL%%', '%%SELECTED_MAILS%%'), + array($mails[0], $selected_mails), + $confirm_delete_mail); + + echo $instance; +?> \ No newline at end of file diff --git a/code/ryzom/tools/server/www/create_thread.php b/code/ryzom/tools/server/www/create_thread.php new file mode 100644 index 000000000..944efde4f --- /dev/null +++ b/code/ryzom/tools/server/www/create_thread.php @@ -0,0 +1,71 @@ + \ No newline at end of file diff --git a/code/ryzom/tools/server/www/form_post.php b/code/ryzom/tools/server/www/form_post.php new file mode 100644 index 000000000..b9ca545fa --- /dev/null +++ b/code/ryzom/tools/server/www/form_post.php @@ -0,0 +1,135 @@ +\n". + "