//执行数据操作语言(DML)类语句 bool CMysqlStore::Query(const std::string &dml) { //清除缓冲 Clear(); if(mysql_query(m_connptr,dml.c_str()) != 0) //if(mysql_real_query(m_connptr,dml.c_str(), dml.length()) != 0) { m_err = mysql_error(m_connptr); return false; } do { m_resultptr = mysql_store_result(m_connptr); if(m_resultptr == NULL) continue; //得到查询返回的行数 m_row += (unsigned long)mysql_affected_rows(m_connptr); //指向 mysql 的查询字段集 MYSQL_FIELD *fieldptr = NULL; //取得各字段名和类型 while(fieldptr = mysql_fetch_field(m_resultptr)) { typeset_t typeset; typeset.index = (unsigned int)m_fieldtype.size(); typeset.length = fieldptr->length; typeset.name = fieldptr->name; typeset.type = SetFieldType(fieldptr->type); m_fieldtype.push_back(typeset); } MYSQL_ROW currrow = NULL; while((currrow = mysql_fetch_row(m_resultptr))) { //读行的记录 const unsigned int colcount = mysql_num_fields(m_resultptr); m_colcount = colcount; row_t rows(colcount); for(unsigned int i = 0; i < colcount; ++i) { rows[i] = currrow[i] ? currrow[i] : "NULL"; } m_recordset.push_back(rows); } mysql_free_result(m_resultptr); m_resultptr = NULL; } while(!mysql_next_result(m_connptr)); return true; }
bool COperMysql::Select(string &dml) { Clear();//清除缓冲 if(mysql_query(m_PtrCon,dml.c_str()) != 0) { //m_Err = mysql_error(m_PtrCon); ZeroMemory(m_szErr, sizeof(m_szErr)); strcpy(m_szErr, mysql_error(m_PtrCon)); TRACE(TEXT(" 操作失败.........")); return false; } m_PtrRes = mysql_store_result(m_PtrCon); //将查询的全部结果读取到客户端 //如果查询未返回结果集 将返回Null指针 //如果读取结果集失败 if (m_PtrCon == NULL) { ZeroMemory(m_szErr, sizeof(m_szErr)); strcpy(m_szErr, mysql_error(m_PtrCon)); //m_Err = mysql_error(m_PtrCon); TRACEA(m_szErr); } m_Row = (WORD)mysql_affected_rows(m_PtrCon); //得到查询返回的行数 MYSQL_FIELD *fieldptr = NULL; //指向 mysql 的查询字段集 while(fieldptr = mysql_fetch_field(m_PtrRes))//取得各字段名和类型 { //从结果集中取得列信息并作为对象返回 typeset_t typeset; typeset.m_index = m_Fieldtype.size(); typeset.m_length = (WORD)fieldptr->length; typeset.m_name = fieldptr->name; typeset.m_type = SetFieldType(fieldptr->type);// m_Fieldtype.push_back(typeset); } MYSQL_ROW currrow = NULL; while((currrow = mysql_fetch_row(m_PtrRes))) //读行的记录 { const unsigned int colcount = mysql_num_fields(m_PtrRes);//取得返回字段的数目 row_t rows(colcount); for(unsigned int i = 0; i < colcount; ++i) { rows[i] = currrow[i] ? currrow[i] : "NULL"; } m_Recordset.push_back(rows); } mysql_free_result(m_PtrRes);//函数释放结果内存 m_PtrRes = NULL; return TRUE; }
//执行数据操作语言(DML)类语句 bool COperMysql::Query(const std::string &dml) { //清除缓冲 Clear(); if(mysql_query(m_PtrCon, dml.c_str()) != 0) { ZeroMemory(m_szErr, sizeof(m_szErr)); strcpy(m_szErr, mysql_error(m_PtrCon)); //m_Err = mysql_error(m_PtrCon); return false; } m_PtrRes = mysql_store_result(m_PtrCon); //得到查询返回的行数 m_Row = (WORD)mysql_affected_rows(m_PtrCon); //指向 mysql 的查询字段集 MYSQL_FIELD *fieldptr = NULL; //取得各字段名和类型 while(fieldptr = mysql_fetch_field(m_PtrRes)) { typeset_t typeset; typeset.m_index = m_Fieldtype.size(); typeset.m_length = (WORD)fieldptr->length; typeset.m_name = fieldptr->name; typeset.m_type = SetFieldType(fieldptr->type); m_Fieldtype.push_back(typeset); } MYSQL_ROW currrow = NULL; while((currrow = mysql_fetch_row(m_PtrRes))) { //读行的记录 const unsigned int colcount = mysql_num_fields(m_PtrRes); row_t rows(colcount); for(unsigned int i = 0; i < colcount; ++i) { rows[i] = currrow[i] ? currrow[i] : "NULL"; } m_Recordset.push_back(rows); } mysql_free_result(m_PtrRes); m_PtrRes = NULL; return true; }
CDrawField::CDrawField() /* ============================================================ Function : CDrawField::CDrawField Description : Constructor. Access : Public Return : void Parameters : none Usage : ============================================================*/ { SetFieldType( FIELD_TYPE_FIELD ); }
CDrawGrid::CDrawGrid() /* ============================================================ Function : CDrawGrid::CDrawGrid Description : Constructor. Access : Public Return : void Parameters : none Usage : ============================================================*/ { SetFieldType( FIELD_TYPE_GRID ); SetPageOffset( 0 ); }
static void TileLoop_Clear(TileIndex tile) { /* If the tile is at any edge flood it to prevent maps without water. */ if (_settings_game.construction.freeform_edges && DistanceFromEdge(tile) == 1) { int z; if (IsTileFlat(tile, &z) && z == 0) { DoFloodTile(tile); MarkTileDirtyByTile(tile); return; } } AmbientSoundEffect(tile); switch (_settings_game.game_creation.landscape) { case LT_TROPIC: TileLoopClearDesert(tile); break; case LT_ARCTIC: TileLoopClearAlps(tile); break; } switch (GetClearGround(tile)) { case CLEAR_GRASS: if (GetClearDensity(tile) == 3) return; if (_game_mode != GM_EDITOR) { if (GetClearCounter(tile) < 7) { AddClearCounter(tile, 1); return; } else { SetClearCounter(tile, 0); AddClearDensity(tile, 1); } } else { SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3); } break; case CLEAR_FIELDS: UpdateFences(tile); if (_game_mode == GM_EDITOR) return; if (GetClearCounter(tile) < 7) { AddClearCounter(tile, 1); return; } else { SetClearCounter(tile, 0); } if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) { /* This farmfield is no longer farmfield, so make it grass again */ MakeClear(tile, CLEAR_GRASS, 2); } else { uint field_type = GetFieldType(tile); field_type = (field_type < 8) ? field_type + 1 : 0; SetFieldType(tile, field_type); } break; default: return; } MarkTileDirtyByTile(tile); }