PageRenderTime 42ms CodeModel.GetById 1ms app.highlight 37ms RepoModel.GetById 1ms app.codeStats 0ms

/TGame/TServerMS/Database/DBMessageHandlerItem.cpp

http://awoe.googlecode.com/
C++ | 158 lines | 113 code | 32 blank | 13 comment | 9 complexity | 6797ac6b204749a484210ce1256a1811 MD5 | raw file
  1//
  2//	Generated by lua
  3//	2009-2011	(C) Simplay Inc. Reserved
  4//
  5//
  6#include "stdafx.h"
  7#include "DBMessageHandlerItem.h"
  8#include "Message/DBMessageItem.h"
  9
 10
 11
 12//
 13//	Dabase Message Handler for LoadItems//
 14
 15DBMessageHandlerLoadItems::DBMessageHandlerLoadItems( void )
 16{
 17}
 18
 19DBMessageHandlerLoadItems::~DBMessageHandlerLoadItems( void )
 20{
 21}
 22
 23bool DBMessageHandlerLoadItems::handleMsg( IMsg * message )
 24{
 25	MsgLoadItems* msg = dynamic_cast< MsgLoadItems * >( message );
 26	Assert( msg && message );
 27
 28	SQL_QUERY( "call load_items(%d)", msg->pid );
 29
 30	if ( sqlResult >= 0 )
 31	{
 32		while ( m_DBMysql.GetRow() )
 33		{
 34				DBItem 	o;
 35				m_DBMysql.GetField(o.iid, 0 );
 36				m_DBMysql.GetField(o.sid, 1 );
 37				m_DBMysql.GetField(o.endurance, 2 );
 38				m_DBMysql.GetField(o.count, 3 );
 39				m_DBMysql.GetField(o.pos, 4 );
 40				m_DBMysql.GetField(o.elvl, 5 );
 41				m_DBMysql.GetField(o.slotcnt, 6 );
 42				m_DBMysql.GetField(o.slot[0], 7 );
 43				m_DBMysql.GetField(o.slot[1], 8 );
 44				m_DBMysql.GetField(o.slot[2], 9 );
 45				m_DBMysql.GetField(o.datax, 10 );
 46				m_DBMysql.GetField(o.datay, 11 );
 47				m_DBMysql.GetField(o.dataz, 12 );
 48				msg->items.push_back(o);
 49		}
 50		msg->m_errcode = Msg::ecSuccess;
 51	}
 52	else
 53	{
 54		LOG_ERROR("Failed to handle db msg: MsgLoadItems , DBMessageHandlerLoadItems!");
 55		msg->m_errcode = Msg::ecFailed;
 56		return false;
 57	}
 58
 59	return true;
 60}
 61
 62//
 63//	Dabase Message Handler for CreateItem//
 64
 65DBMessageHandlerCreateItem::DBMessageHandlerCreateItem( void )
 66{
 67}
 68
 69DBMessageHandlerCreateItem::~DBMessageHandlerCreateItem( void )
 70{
 71}
 72
 73bool DBMessageHandlerCreateItem::handleMsg( IMsg * message )
 74{
 75	MsgCreateItem* msg = dynamic_cast< MsgCreateItem * >( message );
 76	Assert( msg && message );
 77
 78	SQL_QUERY( "call create_item(%d, %d, %d, %d, %d, %c, %c, %d, %d, %d, %d, %d, %d)", msg->pid, msg->item.iid, msg->item.sid, msg->item.endurance, msg->item.count, msg->item.pos, msg->item.elvl, msg->item.slotcnt, msg->item.slot[0], msg->item.slot[1], msg->item.slot[2], msg->item.datax, msg->item.datay, msg->item.dataz );
 79
 80	if ( sqlResult >= 0 )
 81	{
 82		msg->m_errcode = Msg::ecSuccess;
 83	}
 84	else
 85	{
 86		LOG_ERROR("Failed to handle db msg: MsgCreateItem , DBMessageHandlerCreateItem!");
 87		msg->m_errcode = Msg::ecFailed;
 88		return false;
 89	}
 90
 91	return true;
 92}
 93
 94//
 95//	Dabase Message Handler for UpdateItem//
 96
 97DBMessageHandlerUpdateItem::DBMessageHandlerUpdateItem( void )
 98{
 99}
100
101DBMessageHandlerUpdateItem::~DBMessageHandlerUpdateItem( void )
102{
103}
104
105bool DBMessageHandlerUpdateItem::handleMsg( IMsg * message )
106{
107	MsgUpdateItem* msg = dynamic_cast< MsgUpdateItem * >( message );
108	Assert( msg && message );
109
110	SQL_QUERY( "call update_item(%d, %d, %d, %d, %d, %c, %c, %d, %d, %d, %d, %d, %d)", msg->pid, msg->item.iid, msg->item.sid, msg->item.endurance, msg->item.count, msg->item.pos, msg->item.elvl, msg->item.slotcnt, msg->item.slot[0], msg->item.slot[1], msg->item.slot[2], msg->item.datax, msg->item.datay, msg->item.dataz );
111
112	if ( sqlResult >= 0 )
113	{
114		msg->m_errcode = Msg::ecSuccess;
115	}
116	else
117	{
118		LOG_ERROR("Failed to handle db msg: MsgUpdateItem , DBMessageHandlerUpdateItem!");
119		msg->m_errcode = Msg::ecFailed;
120		return false;
121	}
122
123	return true;
124}
125
126//
127//	Dabase Message Handler for RemoveItem//
128
129DBMessageHandlerRemoveItem::DBMessageHandlerRemoveItem( void )
130{
131}
132
133DBMessageHandlerRemoveItem::~DBMessageHandlerRemoveItem( void )
134{
135}
136
137bool DBMessageHandlerRemoveItem::handleMsg( IMsg * message )
138{
139	MsgRemoveItem* msg = dynamic_cast< MsgRemoveItem * >( message );
140	Assert( msg && message );
141
142	SQL_QUERY( "call remove_item(%d, %d)", msg->pid, msg->iid );
143
144	if ( sqlResult >= 0 )
145	{
146		msg->m_errcode = Msg::ecSuccess;
147	}
148	else
149	{
150		LOG_ERROR("Failed to handle db msg: MsgRemoveItem , DBMessageHandlerRemoveItem!");
151		msg->m_errcode = Msg::ecFailed;
152		return false;
153	}
154
155	return true;
156}
157
158