// Pretend you didn't see me. This really needs to go (just copying official) bool CUser::CheckExistItemAnd(int32 nItemID1, int16 sCount1, int32 nItemID2, int16 sCount2, int32 nItemID3, int16 sCount3, int32 nItemID4, int16 sCount4, int32 nItemID5, int16 sCount5) { if (nItemID1 && !CheckExistItem(nItemID1, sCount1)) return false; if (nItemID2 && !CheckExistItem(nItemID2, sCount2)) return false; if (nItemID3 && !CheckExistItem(nItemID3, sCount3)) return false; if (nItemID4 && !CheckExistItem(nItemID4, sCount4)) return false; if (nItemID5 && !CheckExistItem(nItemID5, sCount5)) return false; return true; }
point_itemnode LRParsing::GoTo(point_itemnode IS, grammer sym_val){ int r_num, d_num; grammer SymAfterDot; point_itemnode cursor, New_Item, Go_To_Result_List = NULL, temp_item = NULL; //point_itemnode i_cursor; cursor = IS; while(cursor){ //curr노드의 rule번호 r_num = cursor->RuleNum; d_num = cursor->DotNum; //dot이 맨 끝에 존재하는 아이템은 무시. if(d_num >= rule_v[r_num].rule_len){ cursor = cursor->link; continue; } SymAfterDot = rule_v[r_num].right[d_num]; //점 다음의 심볼과 goto할 심볼이 다르면 다음 아이템으로 넘어 감. if(!(SymAfterDot.select == sym_val.select && SymAfterDot.location == sym_val.location)){ cursor = cursor->link; continue; } //도트를 한칸 우측으로 옮긴 아이템 생성 New_Item = (point_itemnode) malloc(sizeof(typeitemnode)); New_Item->DotNum = d_num+1; New_Item->RuleNum = r_num; New_Item->link = NULL; //New_Item가 이미 존재하면 다음 cursor로 스킵. if(CheckExistItem(Go_To_Result_List,New_Item)){ free(New_Item); cursor = cursor->link; continue; } //NewItemNodePtr를 Go_To_Result_List의 맨 뒤에 붙인다. if(Go_To_Result_List == NULL){ Go_To_Result_List = New_Item; }else{ temp_item = getLastItem(Go_To_Result_List); temp_item->link = New_Item; }//if cursor = cursor->link; }//while : cursor if(Go_To_Result_List) return closure(Go_To_Result_List); else return NULL; }//GoTo()
point_itemnode LRParsing::closure(point_itemnode IS){ //지역변수 선언 point_itemnode new_cs, curr, cursor; grammer SymAfterDot; int r_num, d_num; int i_0 = 0; //포인터 curr가 CS의 첫 노드를 가리키게 한다. curr = IS; //Core Routine while(curr){ //curr 노드의 rule번호 r_num = curr->RuleNum; d_num = curr->DotNum; //SynAfterDot : type.grammer {int select / int location} SymAfterDot = rule_v[r_num].right[d_num]; //단말기호이면 무시하고 넘어간다. if(!SymAfterDot.select){ curr = curr->link; continue; }//if:select == 0 for(i_0 = 0; i_0<23; i_0++){ //룰 i_0의 좌측 심볼이 SymAfterDot이 //아니면 continue if(rule_v[i_0].left.location != SymAfterDot.location) continue; //item node 하나를 만든다. new_cs=(point_itemnode)malloc(sizeof(typeitemnode)); //rule 번호 r; dot number = 0 을 여기에 넣는다. new_cs->RuleNum = i_0; new_cs->DotNum = 0; new_cs->link=NULL; //new_cs가 이미 존재하면 continue if(CheckExistItem(IS, new_cs)){ free(new_cs); continue; }//if : CheckExistItem() //NewItemNodePtr를 CS의 맨 뒤에 붙인다. cursor = getLastItem(IS); cursor->link = new_cs; }//for : i_0 curr = curr->link; }//while : curr return IS; }//closure()
BOOL CUser::CheckEventLogic(EVENT_DATA *pEventData) // This part reads all the 'A' parts and checks if the { // requirements for the 'E' parts are met. if( !pEventData ) return FALSE; BOOL bExact = TRUE; list<LOGIC_ELSE*>::iterator Iter; for( Iter = pEventData->m_arLogicElse.begin(); Iter != pEventData->m_arLogicElse.end(); Iter++ ) { bExact = FALSE; LOGIC_ELSE* pLE = (*Iter); if( !pLE ) return FALSE; switch( pLE->m_LogicElse ) { case LOGIC_CHECK_UNDER_WEIGHT: if( pLE->m_LogicElseInt[0]+m_sItemWeight >= m_sMaxWeight ) bExact = TRUE; break; case LOGIC_CHECK_OVER_WEIGHT: if( pLE->m_LogicElseInt[0]+m_sItemWeight < m_sMaxWeight ) bExact = TRUE; break; case LOGIC_CHECK_SKILL_POINT: if( CheckSkillPoint(pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1], pLE->m_LogicElseInt[2]) ) bExact = TRUE; break; case LOGIC_EXIST_ITEM: if ( CheckExistItem(pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1]) ) bExact = TRUE; break; case LOGIC_CHECK_CLASS: if (CheckClass( pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1], pLE->m_LogicElseInt[2], pLE->m_LogicElseInt[3], pLE->m_LogicElseInt[4], pLE->m_LogicElseInt[5])) { bExact = TRUE; } break; case LOGIC_CHECK_WEIGHT: if (!CheckWeight( pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1])) { bExact = TRUE; } break; case LOGIC_RAND: if (CheckRandom(pLE->m_LogicElseInt[0])) { bExact = TRUE; } break; // // ????? ???? >.< case LOGIC_CHECK_LEVEL: if( m_pUserData->m_bLevel >= pLE->m_LogicElseInt[0] && m_pUserData->m_bLevel <= pLE->m_LogicElseInt[1] ) { bExact = TRUE; } break; case LOGIC_NOEXIST_COM_EVENT: if (!ExistComEvent(pLE->m_LogicElseInt[0])) { bExact = TRUE; } break; case LOGIC_EXIST_COM_EVENT: if (ExistComEvent(pLE->m_LogicElseInt[0])) { bExact = TRUE; } break; case LOGIC_HOWMUCH_ITEM: if ( CheckItemCount(pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1], pLE->m_LogicElseInt[2]) ) { bExact = TRUE; } break; case LOGIC_CHECK_NOAH: if ( m_pUserData->m_iGold >= pLE->m_LogicElseInt[0] && m_pUserData->m_iGold <= pLE->m_LogicElseInt[1] ) { bExact = TRUE; } break; // // /* case LOGIC_CHECK_NATION: if( pLE->m_LogicElseInt[0] == m_pUserData->m_bNation ) { bExact = TRUE; } break; case LOGIC_CHECK_LEVEL: if( m_pUserData->m_bLevel >= pLE->m_LogicElseInt[0] && m_pUserData->m_bLevel <= pLE->m_LogicElseInt[1] ) { bExact = TRUE; } break; case LOGIC_NOEXIST_ITEM: if (ItemCountChange(pLE->m_LogicElseInt[0], 1, 0) < 2) { bExact = TRUE; } break; case LOGIC_QUEST_END: break; case LOGIC_QUEST_LOG: break; case LOGIC_CHECK_NOAH: if(m_pUserData->m_iGold >= pLE->m_LogicElseInt[0]) { bExact = TRUE; } break; case LOGIC_CHECK_RACE: if (pLE->m_LogicElseInt[0] == m_pUserData->m_bRace) { bExact = TRUE; } break; ///////// These logics are for the test quest. case LOGIC_EXIST_ITEM: if (CheckExistItem(pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1])) { bExact = TRUE; } break; case LOGIC_CHECK_CLASS: if (CheckClass( pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1], pLE->m_LogicElseInt[2], pLE->m_LogicElseInt[3], pLE->m_LogicElseInt[4], pLE->m_LogicElseInt[5])) { bExact = TRUE; } break; case LOGIC_CHECK_WEIGHT: if (CheckWeight( pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1])) { bExact = TRUE; } break; case LOGIC_CHECK_SKILLPOINT: if (CheckSkillPoint(pLE->m_LogicElseInt[0], pLE->m_LogicElseInt[1], pLE->m_LogicElseInt[2])) { bExact = TRUE; } break; */ default: return FALSE; } if( !pLE->m_bAnd ) { // OR ????? ??? bExact?? TRUE??? ??ü?? TRUE??? if(bExact) return TRUE; } else { // AND ????? ??? bExact?? FALSE??? ??ü?? FALSE??? if(!bExact) return FALSE; } } return bExact; }