|
You last visited: Today at 13:59
Advertisement
inheritance vs composition
Discussion on inheritance vs composition within the CO2 Programming forum part of the Conquer Online 2 category.
06/18/2013, 12:33
|
#16
|
elite*gold: 0
Join Date: Mar 2013
Posts: 118
Received Thanks: 95
|
If you want a good CO related C++ reference, you should just take a look at the Eudemons client/server source code, it's publicly available. Don't think it's allowed to be posted here because of copyrights though
|
|
|
06/18/2013, 13:52
|
#17
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Quote:
Originally Posted by Smaehtin
If you want a good CO related C++ reference, you should just take a look at the Eudemons client/server source code, it's publicly available. Don't think it's allowed to be posted here because of copyrights though
|
I think it's already posted in the EO section.
|
|
|
06/18/2013, 17:55
|
#18
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by Smaehtin
If you want a good CO related C++ reference, you should just take a look at the Eudemons client/server source code, it's publicly available. Don't think it's allowed to be posted here because of copyrights though
|
Worth noting that its a good CO source, but the code is awful.
|
|
|
06/18/2013, 18:12
|
#19
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Quote:
Originally Posted by Smaehtin
If you want a good CO related C++ reference, you should just take a look at the Eudemons client/server source code, it's publicly available. Don't think it's allowed to be posted here because of copyrights though
|
Or this:
And this:
|
|
|
06/18/2013, 19:21
|
#20
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
Quote:
Originally Posted by Super Aids
Or this:
And this:

|
that's what im actually doing  still trying to fully understand hybrids, some stuff isn't clear and im so tempted to ask but still trying more on my own XD
|
|
|
06/18/2013, 21:02
|
#21
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
I've nerver really looked at Hybrid converted source, but bone's one isn't a good reference.
|
|
|
06/18/2013, 21:08
|
#22
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
|
mine was aimed at just experimenting with managed c++, I wouldn't call it a goof ref' either lol
|
|
|
06/18/2013, 21:11
|
#23
|
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
|
Quote:
Originally Posted by CptSky
I've nerver really looked at Hybrid converted source, but bone's one isn't a good reference.
|
Thank *** somebody else agrees with me.
If I ever get round to actually furthering my c++ source I may just release it here/make it open source, I don't have the finances or resources to run a server myself.
|
|
|
06/19/2013, 01:00
|
#24
|
elite*gold: 0
Join Date: Mar 2013
Posts: 118
Received Thanks: 95
|
Quote:
Originally Posted by Korvacs
Worth noting that its a good CO source, but the code is awful.
|
The code is still 1000-3000% better than 99.99999999999998% of anything ever released here on epvp
|
|
|
06/19/2013, 01:19
|
#25
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
Quote:
Originally Posted by © Haydz
Thank god somebody else agrees with me. [...]
|
Anybody saying that bone's source is good, or fine, is a poor C++ developer.
Quote:
Originally Posted by Smaehtin
The code is still 1000-3000% better than 99.99999999999998% of anything ever released here on epvp 
|
Mhm, I wouldn't say 1000-3000%  It's far from being exceptional. TQ's code is fine, and the code is only good as reference.
Quote:
Originally Posted by InfamousNoone
mine was aimed at just experimenting with managed c++, I wouldn't call it a goof ref' either lol
|
Well, I think there is NO good reference of CO2 source. Plus, if it's Managed-C++, it's kind of unrelated.
|
|
|
06/19/2013, 01:32
|
#26
|
elite*gold: 0
Join Date: Mar 2013
Posts: 118
Received Thanks: 95
|
Quote:
Originally Posted by CptSky
Mhm, I wouldn't say 1000-3000%  It's far from being exceptional. TQ's code is fine, and the code is only good as reference.
|
Have you actually downloaded and looked at most of the releases here on epvp? Most, 9/10 at least, of the private servers are ridiculously poorly designed and written. I'm not judging though, designing and coding a private server isn't really a one or two man job.
|
|
|
06/19/2013, 01:36
|
#27
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Quote:
Originally Posted by CptSky
Well, I think there is NO good reference of CO2 source. Plus, if it's Managed-C++, it's kind of unrelated.
|
The one I referenced was not managed C++, it was native C++ and was a conversion of the 5017 source.
|
|
|
06/19/2013, 01:51
|
#28
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by Smaehtin
The code is still 1000-3000% better than 99.99999999999998% of anything ever released here on epvp 
|
Are you kidding? Its good in the sense that its the closest thing to the legit conquer source code available, but have you actually ever tried going through it? Its a pretty awful example of C++, beaten only by Bone's source, and that's saying something.
|
|
|
06/19/2013, 13:38
|
#29
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
Little example for go for it, from my EoF emulator. It's only the headers and it's not complete, but the general structure of inheritance is there.
No shared method for the moment.
Entity:
Code:
/**
* ****** Faith Emulator - Closed Source ******
* Copyright (C) 2012 - 2013 CptSky
*
* Please read the WARNING, DISCLAIMER and PATENTS
* sections in the LICENSE file.
*/
#ifndef _FAITH_EMULATOR_ENTITY_H
#define _FAITH_EMULATOR_ENTITY_H
#include "common.h"
/**
* Base class of all entity on a map.
*/
class Entity
{
public:
/** First valid UID for a NPC. */
static const int32_t SCENEID_FIRST = 1;
/** First valid UID for a system NPC. */
static const int32_t SYSNPCID_FIRST = 1;
/** Last valid UID for a system NPC. */
static const int32_t SYSNPCID_LAST = 99999;
/** First valid UID for a user/dynamic NPC. */
static const int32_t DYNANPCID_FIRST = 100001;
/** Last valid UID for a user/dynamic NPC. */
static const int32_t DYNANPCID_LAST = 199999;
/** Last valid UID for a NPC. */
static const int32_t SCENEID_LAST = 299999;
/** First valid UID for an advanced NPC. */
static const int32_t NPCSERVERID_FIRST = 400001;
/** First valid UID for a monster. */
static const int32_t MONSTERID_FIRST = 400001;
/** Last valid UID for a monster. */
static const int32_t MONSTERID_LAST = 499999;
/** First valid UID for a pet. */
static const int32_t PETID_FIRST = 500001;
/** Last valid UID for a pet. */
static const int32_t PETID_LAST = 599999;
/** Last valid UID for an advanced NPC. */
static const int32_t NPCSERVERID_LAST = 699999;
/** First valid UID for a called pet. */
static const int32_t CALLPETID_FIRST = 700001;
/** Last valid UID for a called pet. */
static const int32_t CALLPETID_LAST = 799999;
// unused for the moment ?
static const int32_t TRAPID_FIRST = 900001;
static const int32_t MAGICTRAPID_FIRST = 900001;
static const int32_t MAGICTRAPID_LAST = 989999;
static const int32_t SYSTRAPID_FIRST = 990001;
static const int32_t SYSTRAPID_LAST = 999999;
static const int32_t TRAPID_LAST = 999999;
/** First valid UID for a player. */
static const int32_t PLAYERID_FIRST = 1000000;
/** Last valid UID for a player. */
static const int32_t PLAYERID_LAST = 1999999999;
public:
/** Number of cells per block. */
static const int32_t CELLS_PER_BLOCK = 18;
/** Number of cells per view. */
static const int32_t CELLS_PER_VIEW = 18;
public:
/** Determine wheter or not the entity linked to the UID is a NPC. */
static bool isNpc(int32_t aUID) { return aUID >= SCENEID_FIRST && aUID <= SCENEID_LAST; }
/** Determine wheter or not the entity linked to the UID is a system NPC. */
static bool isSysNpc(int32_t aUID) { return aUID >= SYSNPCID_FIRST && aUID <= SYSNPCID_LAST; }
/** Determine wheter or not the entity linked to the UID is a user/dynamic NPC. */
static bool isDynNpc(int32_t aUID) { return aUID >= DYNANPCID_FIRST && aUID <= DYNANPCID_LAST; }
/** Determine wheter or not the entity linked to the UID is a monster. */
static bool isMonster(int32_t aUID) { return aUID >= MONSTERID_FIRST && aUID <= MONSTERID_LAST; }
/** Determine wheter or not the entity linked to the UID is a pet. */
static bool isPet(int32_t aUID) { return aUID >= PETID_FIRST && aUID <= PETID_LAST; }
/** Determine wheter or not the entity linked to the UID is a called pet. */
static bool isCallPet(int32_t aUID) { return aUID >= CALLPETID_FIRST && aUID <= CALLPETID_LAST; }
/** Determine wheter or not the entity linked to the UID is a player. */
static bool isPlayer(int32_t aUID) { return aUID >= PLAYERID_FIRST && aUID <= PLAYERID_LAST; }
public:
/** Determine wheter or not the entity is a NPC. */
bool isNpc() { return isNpc(mUID); }
/** Determine wheter or not the entity is a system NPC. */
bool isSysNpc() { return isSysNpc(mUID); }
/** Determine wheter or not the entity is a user/dynamic NPC. */
bool isDynNpc() { return isDynNpc(mUID); }
/** Determine wheter or not the entity is a monster. */
bool isMonster() { return isMonster(mUID); }
/** Determine wheter or not the entity is a pet. */
bool isPet() { return isPet(mUID); }
/** Determine wheter or not the entity is a called pet. */
bool isCallPet() { return isCallPet(mUID); }
/** Determine wheter or not the entity is a player. */
bool isPlayer() { return isPlayer(mUID); }
public:
/* destructor */
virtual ~Entity();
public:
/** Get the entity's UID. */
int32_t getUID() { return mUID; }
/** Get the entity's name. */
const char* getName() { return (mName.empty() ? nullptr : mName.c_str()); }
/** Get the entity's look/face. */
int32_t getLook() { return mLook; }
/** Get the entity's map UID. */
int16_t getMapId() { return mMapId; }
/** Get the entity's X coord. */
uint16_t getPosX() { return mPosX; }
/** Get the entity's Y coord. */
uint16_t getPosY() { return mPosY; }
/** Get the cardinal direction of the entity. */
uint8_t getDirection() { return mDirection; }
/** Set the map UID of the entity. */
void setMapId(int16_t aMapId) { mMapId = aMapId; }
/** Set the position on the map of the entity. */
void setPosition(uint16_t aPosX, uint16_t aPosY) { mPosX = aPosX; mPosY = aPosY; }
/** Set the cardinal direction of the entity. */
void setDirection(uint8_t aDirection) { mDirection = aDirection; }
protected:
/* constructor */
Entity(int32_t aUID);
protected:
const int32_t mUID; //!< Entity UID
std::string mName; //!< Entity name
int32_t mLook; //!< Entity look/face
int16_t mMapId; //!< Entity map UID
uint16_t mPosX; //!< Entity X coord.
uint16_t mPosY; //!< Entity Y coord.
uint8_t mDirection; //!< Entity cardinal direction
};
#endif // _FAITH_EMULATOR_ENTITY_H
AdvancedEntity:
Code:
/**
* ****** Faith Emulator - Closed Source ******
* Copyright (C) 2012 - 2013 CptSky
*
* Please read the WARNING, DISCLAIMER and PATENTS
* sections in the LICENSE file.
*/
#ifndef _FAITH_EMULATOR_ADVANCED_ENTITY_H
#define _FAITH_EMULATOR_ADVANCED_ENTITY_H
#include "common.h"
#include "entity.h"
/**
* Base class of all advanced entity on a map.
* An advanced entity can be in a battle.
*/
class AdvancedEntity : public Entity
{
public:
/* destructor */
virtual ~AdvancedEntity();
public:
/** Get the entity's level. */
uint8_t getLevel() { return mLevel; }
/** Get the entity's current hit points. */
uint16_t getCurHP() { return mCurHP; }
/** Get the entity's max hit points. */
uint16_t getMaxHP() { return mMaxHP; }
protected:
/* constructor */
AdvancedEntity(int32_t aUID);
protected:
uint8_t mLevel; //!< Entity level
uint16_t mCurHP; //!< Entity current HP
uint16_t mMaxHP; //!< Entity max HP
int32_t mMinAtk;
int32_t mMaxAtk;
int32_t mDefense;
uint8_t mDexterity;
uint8_t mDodge;
};
#endif // _FAITH_EMULATOR_ADVANCED_ENTITY_H
Npc:
Code:
/**
* ****** Faith Emulator - Closed Source ******
* Copyright (C) 2012 - 2013 CptSky
*
* Please read the WARNING, DISCLAIMER and PATENTS
* sections in the LICENSE file.
*/
#ifndef _FAITH_EMULATOR_NPC_H
#define _FAITH_EMULATOR_NPC_H
#include "common.h"
#include "entity.h"
#include <string>
class Npc : public Entity
{
public:
// type: 6, 9, 21, 22, 23, 24
public:
Npc(int32_t aUID, const char* aName,
uint8_t aType, int16_t aLook,
int16_t aMapId, uint16_t aPosX, uint16_t aPosY,
uint8_t aBase, uint8_t aSort);
virtual ~Npc();
public:
uint8_t getType() { return mType; }
uint8_t getBase() { return mBase; }
uint8_t getSort() { return mSort; }
private:
uint8_t mType;
uint8_t mBase;
uint8_t mSort;
};
#endif // _FAITH_EMULATOR_NPC_H
Monster:
Code:
/**
* ****** Faith Emulator - Closed Source ******
* Copyright (C) 2012 - 2013 CptSky
*
* Please read the WARNING, DISCLAIMER and PATENTS
* sections in the LICENSE file.
*/
#ifndef _FAITH_EMULATOR_MONSTER_H
#define _FAITH_EMULATOR_MONSTER_H
#include "common.h"
#include "advancedentity.h"
#include <string>
class Monster : public AdvancedEntity
{
public:
struct Info
{
public:
int32_t Id;
std::string Name;
uint8_t Type;
int32_t Look;
uint8_t Level;
uint16_t Life;
uint16_t EscapeLife;
int32_t MinAtk;
int32_t MaxAtk;
int32_t Defense;
uint8_t Dexterity;
uint8_t Dodge;
uint8_t ViewRange;
uint16_t AtkSpeed;
uint16_t MoveSpeed;
bool Defy;
};
public:
/* destructor */
virtual ~Monster();
protected:
/* constructor */
Monster(int32_t aUID, Monster::Info& aInfo);
private:
int32_t mId;
uint8_t mType;
uint16_t mEscapeLife;
uint8_t mViewRange;
uint16_t mAtkSpeed;
uint16_t mMoveSpeed;
bool mDefy;
};
#endif // _FAITH_EMULATOR_MONSTER_H
Player:
Code:
/**
* ****** Faith Emulator - Closed Source ******
* Copyright (C) 2012 - 2013 CptSky
*
* Please read the WARNING, DISCLAIMER and PATENTS
* sections in the LICENSE file.
*/
#ifndef _FAITH_EMULATOR_PLAYER_H
#define _FAITH_EMULATOR_PLAYER_H
#include "common.h"
#include "advancedentity.h"
#include "client.h"
#include <string>
class Player : public AdvancedEntity
{
public:
Player(Client& aClient);
virtual ~Player();
void enterMap();
void move(uint16_t aX, uint16_t aY, uint8_t);
void sendSysMsg(const char* aFmt, ...);
inline void send(Msg* aMsg) { mClient.send(aMsg); }
inline void send(uint8_t* aBuf, size_t aLen) { mClient.send(aBuf, aLen); }
public:
const char* getMate() { return mMate.c_str(); }
int16_t getHair() { return mHair; }
uint8_t getProfession() { return mProfession; }
uint8_t getMetempsychosis() { return mMetempsychosis; }
int32_t getExp() { return mExp; }
uint16_t getStrength() { return mStrength; }
uint16_t getAgility() { return mAgility; }
uint16_t getVitality() { return mVitality; }
uint16_t getSpirit() { return mSpirit; }
uint16_t getAddPoints() { return mAddPoints; }
uint16_t getCurMP() { return mCurMP; }
uint16_t getMaxMP() { return mMaxMP; }
int32_t getMoney() { return mMoney; }
int16_t getPkPoints() { return mPkPoints; }
int32_t getVirtue() { return mVirtue; }
uint8_t getEnergy() { return mEnergy; }
uint8_t getXP() { return mXP; }
uint16_t getMercenaryExp() { return mMercenaryExp; }
uint16_t getMercenaryLevel() { return mMercenaryLevel; }
private:
Client& mClient;
std::string mMate;
int16_t mHair;
uint8_t mProfession;
uint8_t mMetempsychosis;
int32_t mExp;
uint16_t mStrength;
uint16_t mAgility;
uint16_t mVitality;
uint16_t mSpirit;
uint16_t mAddPoints;
uint16_t mCurMP;
uint16_t mMaxMP;
int32_t mMoney;
int16_t mPkPoints;
int32_t mVirtue;
uint8_t mEnergy;
uint8_t mXP;
uint16_t mMercenaryExp;
uint16_t mMercenaryLevel;
uint16_t mPrevMap;
uint16_t mPrevX;
uint16_t mPrevY;
};
#endif // _FAITH_EMULATOR_PLAYER_H
|
|
|
06/19/2013, 13:44
|
#30
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
well umm sorry for interrupting you guys but umm what should i be doing right now when you all insist that the 3 c++ sources out there sucks  ?
edit : thanks cptsky i like the way you written those classes, the encapsulation and protected modifiers 
edit : was just wondering what you folks mean by it's not good source ? is it the socket/networking or just the whole design ? how far could they be from each others at the sockets , isn't all of them using winsoc or there is some better custom sockets ? please just gimme more details
|
|
|
 |
|
Similar Threads
|
+12 Item Composition
04/10/2011 - CO2 Private Server - 17 Replies
Hi there!
My problem is that I can compose my items till +9 with stones like +1 +2 +3 +4 +5 and +6 , BUT , I can't use +7 / +8 stones.
So it doesn't work to +12 any item , it works only from +1 to +9.
What should I add/modify to get it work till +12 with all kind of stones?
Thanks.
P.S: I can only generate +12 items by command ( /item 14563 12 7 255 13 13 )
If you are a flamer don't comment.
|
[rel] composition fix for 5165
12/09/2009 - CO2 PServer Guides & Releases - 7 Replies
#request close/delete
moved to my multi-rel thread.
|
Composition Chart to +12 any one?
11/28/2007 - Conquer Online 2 - 4 Replies
Just like to know if anyone has a "Composition Chart" to +12 items thanks :)
|
Composition Calculator
09/30/2006 - CO2 Exploits, Hacks & Tools - 14 Replies
Ok, so im a newbie using cotobo for a long time with only a couple of posts. Everybody would want to see if this is clean and all so please somebody scan it.
Why did i make this? Well, i liked the one posted on TQ board but one of the feature never got finished (subtracting what you current have). You can check here
http://shellz2.future-hosting.net/~sony/c ompose.php
This program is written VB and this is my second VB program besides (Hello World) so it's quite ugly and very plain.
...
|
All times are GMT +1. The time now is 13:59.
|
|