//-----private--- void EnemyKingPumpkin::Damage(int damage){ int joinNum = managers->Player()->GetJoinNum(); if (parameter.health > 0){ parameter.health -= damage*(5 - (joinNum+2) / 4); } CheckIsDead(); }
bool CTL_RowResult::Fetch() { SetCurrentItemNum(-1); if ( m_EOR ) { return false; } // Reset NullValue flags ... for (unsigned int nof_items = 0; nof_items < GetDefineParams().GetNum(); ++nof_items) { m_NullValue[nof_items] = eNullUnknown; } CheckIsDead(); switch ( Check(ct_fetch(x_GetSybaseCmd(), CS_UNUSED, CS_UNUSED, CS_UNUSED, 0)) ) { case CS_SUCCEED: SetCurrentItemNum(0); return true; case CS_END_DATA: m_EOR = true; return false; case CS_ROW_FAIL: DATABASE_DRIVER_ERROR( "Error while fetching the row." + GetDbgInfo(), 130003 ); case CS_FAIL: DATABASE_DRIVER_ERROR("ct_fetch has failed. " "You need to cancel the command." + GetDbgInfo(), 130006 ); case CS_CANCELED: DATABASE_DRIVER_ERROR( "The command has been canceled." + GetDbgInfo(), 130004 ); default: DATABASE_DRIVER_ERROR( "The connection is busy." + GetDbgInfo(), 130005 ); } }
bool CTL_BCPInCmd::EndBCP(void) { if(!WasSent()) return false; CheckIsDead(); CS_INT outrow = 0; if (CheckSentSFB(blk_done(x_GetSybaseCmd(), CS_BLK_ALL, &outrow), "blk_done failed", 123020) == CS_SUCCEED) { return (outrow > 0); } return false; }
bool CTL_BCPInCmd::CommitBCPTrans(void) { if(!WasSent()) return false; CheckIsDead(); CS_INT outrow = 0; switch( Check(blk_done(x_GetSybaseCmd(), CS_BLK_BATCH, &outrow)) ) { case CS_SUCCEED: return (outrow > 0); case CS_FAIL: SetHasFailed(); DATABASE_DRIVER_ERROR( "blk_done failed." + GetDbgInfo(), 123020 ); default: return false; } }
bool CTL_BCPInCmd::Send(void) { unsigned int i; CS_INT datalen = 0; size_t len = 0; char buff[2048]; CheckIsDead(); if ( !WasSent() ) { // we need to init the bcp CheckSFB(blk_init(x_GetSybaseCmd(), CS_BLK_IN, (CS_CHAR*) GetQuery().data(), GetQuery().size()), "blk_init failed", 123001); SetWasSent(); // check what needs to be default CS_DATAFMT fmt; for (i = 0; i < GetBindParamsImpl().NofParams(); i++) { if (GetBindParamsImpl().GetParamStatus(i) != 0) { continue; } SetHasFailed((Check(blk_describe(x_GetSybaseCmd(), i + 1, &fmt)) != CS_SUCCEED)); CHECK_DRIVER_ERROR( HasFailed(), "blk_describe failed (check the number of " "columns in a table)." + GetDbgInfo(), 123002 ); } } SetHasFailed(!x_AssignParams()); CHECK_DRIVER_ERROR( HasFailed(), "Cannot assign the params." + GetDbgInfo(), 123004 ); switch ( Check(blk_rowxfer(x_GetSybaseCmd())) ) { case CS_BLK_HAS_TEXT: for (i = 0; i < GetBindParamsImpl().NofParams(); i++) { if (GetBindParamsImpl().GetParamStatus(i) == 0) continue; CDB_Object& param = *GetBindParamsImpl().GetParam(i); if (param.IsNULL()) { continue; } else if (param.GetType() == eDB_Text || param.GetType() == eDB_Image) { CDB_Stream& par = dynamic_cast<CDB_Stream&> (param); for (datalen = (CS_INT) par.Size(); datalen > 0; datalen -= (CS_INT) len) { len = par.Read(buff, sizeof(buff)); SetHasFailed((Check(blk_textxfer(x_GetSybaseCmd(), (CS_BYTE*) buff, (CS_INT) len, 0) ) == CS_FAIL)); CHECK_DRIVER_ERROR( HasFailed(), "blk_textxfer failed for the text/image field." + GetDbgInfo(), 123005 ); } } } case CS_SUCCEED: ++m_RowCount; return true; default: SetHasFailed(); CHECK_DRIVER_ERROR( HasFailed(), "blk_rowxfer failed." + GetDbgInfo(), 123007 ); } return false; }
CTL_RowResult::CTL_RowResult(CS_COMMAND* cmd, CTL_Connection& conn) : m_Connect(&conn), m_Cmd(cmd), m_CurrItem(-1), m_EOR(false), m_BindedCols(0) { CheckIsDead(); CS_INT outlen; CS_INT nof_cols; bool rc = (Check(ct_res_info(x_GetSybaseCmd(), CS_NUMDATA, &nof_cols, CS_UNUSED, &outlen)) != CS_SUCCEED); CHECK_DRIVER_ERROR( rc, "ct_res_info(CS_NUMDATA) failed." + GetDbgInfo(), 130001 ); CS_INT bind_len = 0; m_BindedCols = 0; bool buff_is_full = false; m_ColFmt = AutoArray<CS_DATAFMT>(nof_cols); m_NullValue = AutoArray<ENullValue>(nof_cols); for (unsigned int nof_item = 0; nof_item < (unsigned int) nof_cols; nof_item++) { rc = (Check(ct_describe(x_GetSybaseCmd(), (CS_INT) nof_item + 1, &m_ColFmt[nof_item])) != CS_SUCCEED); CHECK_DRIVER_ERROR( rc, "ct_describe failed." + GetDbgInfo(), 130002 ); m_NullValue[nof_item] = eNullUnknown; #ifdef FTDS_IN_USE // Seems like FreeTDS reports wrong maxlength in // ct_describe() - fix this when binding to a buffer. if (m_ColFmt[nof_item].datatype == CS_NUMERIC_TYPE || m_ColFmt[nof_item].datatype == CS_DECIMAL_TYPE ) { m_ColFmt[nof_item].maxlength = sizeof(CS_NUMERIC); } #endif m_CachedRowInfo.Add( string(m_ColFmt[nof_item].name, m_ColFmt[nof_item].namelen), m_ColFmt[nof_item].maxlength, ConvDataType_Ctlib2DBAPI(m_ColFmt[nof_item]) ); if (!buff_is_full) { if (m_ColFmt[nof_item].maxlength > 2048 || m_ColFmt[nof_item].datatype == CS_IMAGE_TYPE) { buff_is_full = true; } else { bind_len += m_ColFmt[nof_item].maxlength; if (bind_len <= 2048) { m_BindedCols++; } else { buff_is_full = true; } } } } if(m_BindedCols) { m_BindItem = AutoArray<CS_VOID*>(m_BindedCols); m_Copied = AutoArray<CS_INT>(m_BindedCols); m_Indicator = AutoArray<CS_SMALLINT>(m_BindedCols); for(int i= 0; i < m_BindedCols; i++) { m_BindItem[i] = (i ? ((unsigned char*)(m_BindItem[i-1])) + m_ColFmt[i-1].maxlength : m_BindBuff); rc = (Check(ct_bind(x_GetSybaseCmd(), i+1, &m_ColFmt[i], m_BindItem[i], &m_Copied[i], &m_Indicator[i]) ) != CS_SUCCEED); CHECK_DRIVER_ERROR( rc, "ct_bind failed." + GetDbgInfo(), 130042 ); } } }
CS_RETCODE CTL_RowResult::my_ct_get_data(CS_COMMAND* cmd, CS_INT item, CS_VOID* buffer, CS_INT buflen, CS_INT *outlen, bool& is_null) { CheckIsDead(); is_null = false; if(item > m_BindedCols) { // Not bound ... CS_RETCODE rc = Check(ct_get_data(cmd, item, buffer, buflen, outlen)); if ((rc == CS_END_ITEM || rc == CS_END_DATA)) { if (outlen) { #ifdef FTDS_IN_USE if (*outlen == -1) { is_null = true; *outlen = 0; } else is_null = false; #else is_null = (*outlen == 0); #endif } } return rc; } // Bound ... // Move data ... --item; CS_SMALLINT indicator = m_Indicator[item]; CS_INT copied = m_Copied[item]; // if((m_Indicator[item] < 0) || ((CS_INT)m_Indicator[item] >= m_Copied[item])) { if(indicator < 0) { // Value is NULL ... is_null = true; if(outlen) { *outlen = 0; } return CS_END_ITEM; } if(!buffer || (buflen < 1)) { return CS_SUCCEED; } CS_INT n = copied - indicator; if(buflen > n) { buflen = n; } memcpy(buffer, (char*)(m_BindItem[item]) + indicator, buflen); if(outlen) { *outlen = buflen; } m_Indicator[item] += static_cast<CS_SMALLINT>(buflen); return (n == buflen) ? CS_END_ITEM : CS_SUCCEED; }