From: Anders R. <ma...@us...> - 2006-01-02 21:46:50
|
Update of /cvsroot/planeshift/planeshift/src/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15799/src/client Modified Files: pscharcontrol.cpp pscharcontrol.h Log Message: Fixed run failing. Index: pscharcontrol.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/pscharcontrol.cpp,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** pscharcontrol.cpp 24 Dec 2005 02:10:25 -0000 1.148 --- pscharcontrol.cpp 2 Jan 2006 21:46:42 -0000 1.149 *************** *** 73,77 **** { csKeyModifiers mods; ! for(int i = 0; i < 6; i++) { if( this->mods & (1 << i)) --- 73,77 ---- { csKeyModifiers mods; ! for(int i = 0; i < csKeyModifierTypeLast; i++) { if( this->mods & (1 << i)) *************** *** 87,91 **** { csKeyModifiers mods; ! for(int i = 0; i < 6; i++) { if( this->mods & (1 << i)) --- 87,91 ---- { csKeyModifiers mods; ! for(int i = 0; i < csKeyModifierTypeLast; i++) { if( this->mods & (1 << i)) *************** *** 251,254 **** --- 251,257 ---- psengine->GetMsgHandler()->SendMessage(msg.msg); + // For debug dump all initial stores + Dump(); + return true; } *************** *** 260,263 **** --- 263,269 ---- res->to = GetTrigger(to); res->var = var; + + // printf("AddResolver: %s -> %s var: %s\n",res->from->name.GetDataSafe(),res->to->name.GetDataSafe(),res->var.GetDataSafe()); + resolvers.Push(res); } *************** *** 268,271 **** --- 274,278 ---- { psKeyResolver* ctrl = resolvers[i]; + if(ctrl->from == in) { *************** *** 500,504 **** const char* tmp; while((tmp = va_arg(args,const char*)) != NULL) ! cm->mcvs.Push(GetTrigger(tmp)); va_end(args); --- 507,518 ---- const char* tmp; while((tmp = va_arg(args,const char*)) != NULL) ! { ! psControl * trig = GetTrigger(tmp); ! if (trig == NULL) ! { ! Error2("Failed to add modifier for '%s'",tmp); ! } ! cm->mcvs.Push(trig); ! } va_end(args); *************** *** 533,537 **** { trig2 = CreateTrigger(type); ! (*trig2) = (*trig); } else --- 547,558 ---- { trig2 = CreateTrigger(type); ! ! trig2->status = trig->status; ! trig2->keyDown = trig->keyDown; ! trig2->pressType = trig->pressType; ! trig2->name = trig->name; ! trig2->function = trig->function; ! trig2->mods = trig->mods; ! trig2->variant = trig->variant; } else *************** *** 543,553 **** if(trig2 != trig) { // Remove old and add new triggers.Delete(trig); triggers.Push(trig2); } - return true; ! //printf("Remapped %s to controller type %d and trigger %u with mod %u\n",name,type,trigger,mods); } --- 564,605 ---- if(trig2 != trig) { + // Resolvers can point to this trigger. Update resolver + // to point to new allocated trigger. + for (size_t i = 0; i < resolvers.Length();i++) + { + psKeyResolver* key = resolvers[i]; + if (key->to == trig) + { + key->to = trig2; + // printf("Remaping resolver from\n"); + // printf("%s -> %s var: %s\n",key->from->name.GetDataSafe(),key->to->name.GetDataSafe(),key->var.GetDataSafe()); + } + if (key->from == trig) + { + key->from = trig2; + // printf("Remaping resolver from\n"); + // printf("%s -> %s var: %s\n",key->from->name.GetDataSafe(),key->to->name.GetDataSafe(),key->var.GetDataSafe()); + } + } + + // Update modifiers + for(size_t i = 0; i < modifiers.Length();i++) + { + psControlModifier* cm = modifiers[i]; + + for(size_t i = 0; i < cm->mcvs.Length(); i++) + { + if (cm->mcvs[i] == trig) + cm->mcvs[i] = trig2; + } + } + + // Remove old and add new triggers.Delete(trig); triggers.Push(trig2); } ! return true; } *************** *** 639,642 **** --- 691,714 ---- } + void psCharController::Dump() + { + printf("Triggers\n"); + for(size_t i = 0; i < triggers.Length();i++) + { + psControl* trig = triggers[i]; + + printf("Name: %s\n",trig->name.GetDataSafe()); + } + + printf("Resolvers\n"); + for(size_t i = 0; i < resolvers.Length();i++) + { + psKeyResolver* ctrl = resolvers[i]; + printf("From: %s -> %s\n",ctrl->from->name.GetDataSafe(),ctrl->to->name.GetDataSafe()); + } + + } + + void psCharController::ModifierCheck() { *************** *** 770,774 **** csKeyEventHelper::GetEventData (&ev, data); ! // Extract the only data we trust uint32 bits = 0; for(int i = 0; i < 3;i++) --- 842,846 ---- csKeyEventHelper::GetEventData (&ev, data); ! // Extract the only data we trust: shift, ctrl, and alt uint32 bits = 0; for(int i = 0; i < 3;i++) *************** *** 821,825 **** return; ! (this->*(ctrl->function))(Resolve(ctrl),status); // Instant release? --- 893,899 ---- return; ! psControl * resolved = Resolve(ctrl); ! ! (this->*(resolved->function))(resolved,status); // Instant release? *************** *** 848,854 **** void psCharController::PressKey(utf32_char key,uint32 mods) { psControlKey* cKey = (psControlKey*)GetTrigger(key,mods,PSCONTROL_KEY); if(!cKey) ! return; cKey->keyDown = true; --- 922,932 ---- void psCharController::PressKey(utf32_char key,uint32 mods) { + // printf("Key pressed: %u %u\n",key,mods); + psControlKey* cKey = (psControlKey*)GetTrigger(key,mods,PSCONTROL_KEY); if(!cKey) ! return; // Unbound ! ! // printf("Found trigger: %s\n",cKey->name.GetDataSafe()); cKey->keyDown = true; *************** *** 867,870 **** --- 945,950 ---- void psCharController::ReleaseKey(utf32_char key,uint32 mods) { + // printf("Key released: %u %u\n",key,mods); + psControlKey* cKey = (psControlKey*)GetTrigger(key,mods,PSCONTROL_KEY); if(!cKey) *************** *** 873,876 **** --- 953,958 ---- cKey->keyDown = false; + // printf("Found trigger: %s\n",cKey->name.GetDataSafe()); + bool oStat = cKey->status; *************** *** 1124,1128 **** if(sc == 0) { ! printf("Invalid extraction in shortcut handle!\n"); return; } --- 1206,1210 ---- if(sc == 0) { ! Error1("Invalid extraction in shortcut handle!"); return; } *************** *** 1670,1674 **** mov->AddRequirement(mvMsg.reqs[i].str,mvMsg.reqs[i].value); } - } --- 1752,1755 ---- *************** *** 1819,1823 **** --- 1900,1907 ---- psMovement* mov = GetMovement(action); if(!mov) + { + Error3("Can't start action '%s' variant '%s'",action,variant) return; + } // See if the family is applied Index: pscharcontrol.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/pscharcontrol.h,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** pscharcontrol.h 23 Dec 2005 11:47:08 -0000 1.72 --- pscharcontrol.h 2 Jan 2006 21:46:42 -0000 1.73 *************** *** 424,427 **** --- 424,429 ---- uint32 GetActiveModifiers(); + void Dump(); + private: // Private functions |