![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 // TestDLL.cpp : Defines the exported functions for the DLL application. 00002 00003 #include "stdafx.h" 00004 00005 #include <stdio.h> 00006 #include <stdlib.h> 00007 #include <iostream> 00008 #include <map> 00009 #include <memory> 00010 00011 #include <cppconn/driver.h> 00012 #include <cppconn/exception.h> 00013 #include <cppconn/resultset.h> 00014 #include <cppconn/statement.h> 00015 #include <cppconn/prepared_statement.h> 00016 00017 #include "DbConnectionFactory.h" 00018 #include "DbProcedures.h" 00019 00023 INLINE std::string convertString(wchar_t* string) 00024 { 00025 size_t size = wcslen(string); 00026 size_t outCharCount; 00027 char *buf = new char[size]; 00028 wcstombs_s(&outCharCount, buf, size, string, size); 00029 std::string ret(buf); 00030 delete[] buf; 00031 return ret; 00032 } 00033 00037 INLINE wchar_t* convertString(const std::string& string) 00038 { 00039 //the memory allocated here should theoretically be managed by the DLLBind mechanism, so there is no corresponding delete 00040 //If at a later time, we find a memory leak in the applicable, this could be it. 00041 wchar_t *ret = new wchar_t[string.size()]; 00042 00043 size_t size = (size_t)string.size(); 00044 size_t outCharCount; 00045 mbstowcs_s(&outCharCount, ret, size, string.c_str(),size); 00046 return ret; 00047 } 00048 00049 extern "C" 00050 { 00051 __declspec(dllexport) void clearCharQuality(int pInCharId, int pInQualityId) 00052 { 00053 SraData::DbProcedures::clearCharQuality(pInCharId,pInQualityId); 00054 } 00055 00056 00057 __declspec(dllexport) void clearCharSpell(int pInCharId, int pInSpellId) 00058 { 00059 SraData::DbProcedures::clearCharSpell(pInCharId,pInSpellId); 00060 } 00061 00062 00063 __declspec(dllexport) void createCharacter(int pInRaceId, int* pOutId) 00064 { 00065 SraData::DbProcedures::createCharacter(pInRaceId,pOutId); 00066 } 00067 00068 00069 __declspec(dllexport) void createGearItem(int pInGearId, int pInOwnerCharId, int pInRating, int* pOutGearItemId) 00070 { 00071 SraData::DbProcedures::createGearItem(pInGearId,pInOwnerCharId,pInRating,pOutGearItemId); 00072 } 00073 00074 00075 __declspec(dllexport) void createPlayer(wchar_t* pInLogin, wchar_t* pInPassword, int* pOutId) 00076 { 00077 SraData::DbProcedures::createPlayer(convertString(pInLogin),convertString(pInPassword),pOutId); 00078 } 00079 00080 00081 __declspec(dllexport) void createPlayerCharacter(int pInRaceId, int pInPlayerId, int* pOutPcId, int* pOutCharId) 00082 { 00083 SraData::DbProcedures::createPlayerCharacter(pInRaceId,pInPlayerId,pOutPcId,pOutCharId); 00084 } 00085 00086 00087 __declspec(dllexport) void deleteGearItem(int pInGearItemId) 00088 { 00089 SraData::DbProcedures::deleteGearItem(pInGearItemId); 00090 } 00091 00092 00093 __declspec(dllexport) void getChar(int pInCharId, int* isMale, int* raceId, int* agility, int* body, int* reaction, int* strength, int* charisma, int* intuition, int* logic, int* willpower, int* edge, int* edgeBurnt, int* magic, int* resonance, int* queryId) 00094 { 00095 bool isMaleBool; 00096 SraData::DbProcedures::getChar(pInCharId,&isMaleBool,raceId,agility,body,reaction,strength,charisma,intuition,logic,willpower,edge,edgeBurnt,magic,resonance, queryId); 00097 *isMale = isMaleBool ? 1 : 0; 00098 } 00099 00100 00101 __declspec(dllexport) void getCharActiveSkills(int pInCharId, int* activeSkillId, int* rating, int* queryId) 00102 { 00103 SraData::DbProcedures::getCharActiveSkills(pInCharId,activeSkillId,rating, queryId); 00104 } 00105 00106 00107 __declspec(dllexport) void getCharAdeptPwrs(int pInCharId, int* adeptPowerId, int* rating, int* queryId) 00108 { 00109 SraData::DbProcedures::getCharAdeptPwrs(pInCharId,adeptPowerId,rating, queryId); 00110 } 00111 00112 00113 __declspec(dllexport) void getCharDmg(int pInCharId, int* stunDmgTaken, int* physicalDmgTaken, int* queryId) 00114 { 00115 SraData::DbProcedures::getCharDmg(pInCharId,stunDmgTaken,physicalDmgTaken, queryId); 00116 } 00117 00118 00119 __declspec(dllexport) void getCharGear(int pInCharId, int* gearId, int* location, int* rating, int* queryId) 00120 { 00121 SraData::DbProcedures::getCharGear(pInCharId,gearId,location,rating, queryId); 00122 } 00123 00124 00125 __declspec(dllexport) void getCharKnowSkills(int pInCharId, int* knowledgeSkillId, int* rating, int* queryId) 00126 { 00127 SraData::DbProcedures::getCharKnowSkills(pInCharId,knowledgeSkillId,rating, queryId); 00128 } 00129 00130 00131 __declspec(dllexport) void getCharQualities(int pInCharId, int* qualityId, int* rating, int* queryId) 00132 { 00133 SraData::DbProcedures::getCharQualities(pInCharId,qualityId,rating, queryId); 00134 } 00135 00136 00137 __declspec(dllexport) void getCharSpells(int pInCharId, int* spellId, int* queryId) 00138 { 00139 SraData::DbProcedures::getCharSpells(pInCharId,spellId, queryId); 00140 } 00141 00142 00143 __declspec(dllexport) void getPcZone(int pInPcId, int* currentZoneId, int* queryId) 00144 { 00145 SraData::DbProcedures::getPcZone(pInPcId,currentZoneId, queryId); 00146 } 00147 00148 00149 __declspec(dllexport) void getPlayerCharacters(int pInPlayerId, int* ID, int* queryId) 00150 { 00151 SraData::DbProcedures::getPlayerCharacters(pInPlayerId,ID, queryId); 00152 } 00153 00154 00155 __declspec(dllexport) void setCharActiveSkill(int pInCharId, int pInSkillId, int pInRating) 00156 { 00157 SraData::DbProcedures::setCharActiveSkill(pInCharId,pInSkillId,pInRating); 00158 } 00159 00160 00161 __declspec(dllexport) void setCharAdeptPwr(int pInCharId, int pInPwrId, int pInRating) 00162 { 00163 SraData::DbProcedures::setCharAdeptPwr(pInCharId,pInPwrId,pInRating); 00164 } 00165 00166 00167 __declspec(dllexport) void setCharDmg(int pInCharId, int pInStunDmg, int pInPhysDmg) 00168 { 00169 SraData::DbProcedures::setCharDmg(pInCharId,pInStunDmg,pInPhysDmg); 00170 } 00171 00172 00173 __declspec(dllexport) void setCharKnowSkill(int pInCharId, int pInSkillId, int pInRating) 00174 { 00175 SraData::DbProcedures::setCharKnowSkill(pInCharId,pInSkillId,pInRating); 00176 } 00177 00178 00179 __declspec(dllexport) void setCharMentAttr(int pInCharId, int pInCharisma, int pInIntuition, int pInLogic, int pInWillpower) 00180 { 00181 SraData::DbProcedures::setCharMentAttr(pInCharId,pInCharisma,pInIntuition,pInLogic,pInWillpower); 00182 } 00183 00184 00185 __declspec(dllexport) void setCharPhysAttr(int pInCharId, int pInAgility, int pInBody, int pInReaction, int pInStrength) 00186 { 00187 SraData::DbProcedures::setCharPhysAttr(pInCharId,pInAgility,pInBody,pInReaction,pInStrength); 00188 } 00189 00190 00191 __declspec(dllexport) void setCharQuality(int pInCharId, int pInQualityId, int pInRating) 00192 { 00193 SraData::DbProcedures::setCharQuality(pInCharId,pInQualityId,pInRating); 00194 } 00195 00196 00197 __declspec(dllexport) void setCharSpecAttr(int pInCharId, int pInEdge, int pInEdgeBurnt, int pInMagic, int pInResonance) 00198 { 00199 SraData::DbProcedures::setCharSpecAttr(pInCharId,pInEdge,pInEdgeBurnt,pInMagic,pInResonance); 00200 } 00201 00202 00203 __declspec(dllexport) void setCharSpell(int pInCharId, int pInSpellId) 00204 { 00205 SraData::DbProcedures::setCharSpell(pInCharId,pInSpellId); 00206 } 00207 00208 00209 __declspec(dllexport) void setGearItemOwner(int pInGearId, int pInOwnerCharId) 00210 { 00211 SraData::DbProcedures::setGearItemOwner(pInGearId,pInOwnerCharId); 00212 } 00213 00214 00215 __declspec(dllexport) void setPcZone(int pInPcId, int pInZoneId) 00216 { 00217 SraData::DbProcedures::setPcZone(pInPcId,pInZoneId); 00218 } 00219 00220 00221 __declspec(dllexport) void setPlayerNickname(int pInPlayerId, wchar_t* pInNickname) 00222 { 00223 SraData::DbProcedures::setPlayerNickname(pInPlayerId,convertString(pInNickname)); 00224 } 00225 }
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.