1 | /* |
1 | /* |
2 | * static char *rcsid_c_wiz_c = |
2 | * static char *rcsid_c_wiz_c = |
3 | * "$Id: c_wiz.C,v 1.4 2006/08/29 08:01:37 root Exp $"; |
3 | * "$Id: c_wiz.C,v 1.5 2006/08/31 17:54:15 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
1813 | op->contr->stack_position = 0; |
1813 | op->contr->stack_position = 0; |
1814 | new_draw_info(NDI_UNIQUE, 0, op, "Item stack cleared."); |
1814 | new_draw_info(NDI_UNIQUE, 0, op, "Item stack cleared."); |
1815 | return 0; |
1815 | return 0; |
1816 | } |
1816 | } |
1817 | |
1817 | |
1818 | /** |
|
|
1819 | * Get a diff of specified items. |
|
|
1820 | * Second item is compared to first, and differences displayed. |
|
|
1821 | * Note: get_ob_diff works the opposite way (first compared to 2nd), |
|
|
1822 | * but it's easier with stack functions to do it this way, so you can do: |
|
|
1823 | * * stack_push <base> |
|
|
1824 | * * stack_push <object to be compared> |
|
|
1825 | * * diff |
|
|
1826 | * * patch xxx <---- applies to object compared to base, easier :) |
|
|
1827 | * |
|
|
1828 | * Ryo, august 2004 |
|
|
1829 | */ |
|
|
1830 | int command_diff(object *op, char *params) { |
|
|
1831 | object *left, *right, *top; |
|
|
1832 | const char *diff; |
|
|
1833 | int left_from, right_from; |
|
|
1834 | |
|
|
1835 | top = NULL; |
|
|
1836 | |
|
|
1837 | left = get_dm_object(op->contr, ¶ms, &left_from); |
|
|
1838 | if (!left) { |
|
|
1839 | new_draw_info(NDI_UNIQUE, 0, op, "Compare to what item?"); |
|
|
1840 | return 0; |
|
|
1841 | } |
|
|
1842 | |
|
|
1843 | if (left_from == STACK_FROM_NUMBER) |
|
|
1844 | /* Item was stacked, remove it else right will be the same... */ |
|
|
1845 | dm_stack_pop(op->contr); |
|
|
1846 | |
|
|
1847 | right = get_dm_object(op->contr, ¶ms, &right_from); |
|
|
1848 | |
|
|
1849 | if (!right) { |
|
|
1850 | new_draw_info(NDI_UNIQUE, 0, op, "Compare what item?"); |
|
|
1851 | return 0; |
|
|
1852 | } |
|
|
1853 | |
|
|
1854 | new_draw_info(NDI_UNIQUE, 0, op, "Item difference:"); |
|
|
1855 | |
|
|
1856 | if (left_from == STACK_FROM_TOP && right_from == STACK_FROM_TOP) { |
|
|
1857 | /* |
|
|
1858 | * Special case: both items were taken from stack top. |
|
|
1859 | * Override the behaviour, taking left as item just below top, if exists. |
|
|
1860 | * See function description for why. |
|
|
1861 | * Besides, if we don't do anything, compare an item to itself, not really useful. |
|
|
1862 | */ |
|
|
1863 | if (op->contr->stack_position > 1) { |
|
|
1864 | left = find_object(op->contr->stack_items[op->contr->stack_position-2]); |
|
|
1865 | if (left) |
|
|
1866 | new_draw_info(NDI_UNIQUE, 0, op, "(Note: first item taken from undertop)"); |
|
|
1867 | else |
|
|
1868 | /* Stupid case: item under top was freed, fallback to stack top */ |
|
|
1869 | left = right; |
|
|
1870 | } |
|
|
1871 | } |
|
|
1872 | |
|
|
1873 | diff = get_ob_diff(left, right); |
|
|
1874 | |
|
|
1875 | if (!diff) { |
|
|
1876 | new_draw_info(NDI_UNIQUE, 0, op, "Objects are the same."); |
|
|
1877 | return 0; |
|
|
1878 | } |
|
|
1879 | |
|
|
1880 | new_draw_info(NDI_UNIQUE, 0, op, diff); |
|
|
1881 | return 0; |
|
|
1882 | } |
|
|
1883 | |
|
|
1884 | int command_insert_into(object* op, char *params) |
1818 | int command_insert_into(object* op, char *params) |
1885 | { |
1819 | { |
1886 | object *left, *right, *inserted; |
1820 | object *left, *right, *inserted; |
1887 | const char *diff; |
1821 | const char *diff; |
1888 | int left_from, right_from; |
1822 | int left_from, right_from; |