| 676 | } |
| 677 | |
| 678 | static GameValue ListSet(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 679 | { |
| 680 | const GameArrayType& array = oper1; |
| 681 | const GameArrayType& arg = oper2; |
| 682 | if (arg.Size() != 2) |
| 683 | { |
| 684 | state->SetError(EvalDim, array.Size(), 2); |
| 685 | return NOTHING; |
| 686 | } |
| 687 | if (arg[0].GetType() != GameScalar) |
| 688 | { |
| 689 | state->TypeError(GameScalar, arg[0].GetType()); |
| 690 | return NOTHING; |
| 691 | } |
| 692 | |
| 693 | float index = arg[0]; |
| 694 | const GameValue& value = arg[1]; |
| 695 | int sel = toInt(index); |
| 696 | if (sel < 0) |
| 697 | { |
| 698 | state->SetError(EvalDivZero); |
| 699 | return NOTHING; |
| 700 | } |
| 701 | |
| 702 | if (oper1.GetReadOnly()) |
| 703 | { |
| 704 | state->SetError(EvalBadVar); |
| 705 | return NOTHING; |
| 706 | } |
| 707 | GameArrayType& arrayNC = const_cast<GameArrayType&>(array); |
| 708 | arrayNC.Access(sel); // grows the array if needed |
| 709 | // storing an array that contains this array would create a recursive |
| 710 | // structure, which later crashes; reject it instead |
| 711 | if (CheckArrayInValue(array, value)) |
| 712 | { |
| 713 | Fail("Recursive array"); |
| 714 | state->SetError(EvalDim); |
| 715 | return NOTHING; |
| 716 | } |
| 717 | |
| 718 | arrayNC[sel] = value; |
| 719 | |
| 720 | return NOTHING; |
| 721 | } |
| 722 | |
| 723 | static GameValue StringCall(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 724 | { |
nothing calls this directly
no test coverage detected